kekscom / osmbuildings

OSM Buildings Classic 2.5D
http://osmbuildings.org
BSD 2-Clause "Simplified" License
504 stars 140 forks source link

dynamic buildings #26

Closed bennlich closed 11 years ago

bennlich commented 11 years ago

Might be nice to make a public method for modifying building data, so you can make changes on the fly. It could accept an array argument that contains an object per building, where each object contains only the key/value pairs that are to be updated.

kekscom commented 11 years ago

In case of GeoJSON you could already do that. Do you have a more specific use case, i.e. creating an editor?

bennlich commented 11 years ago

Oh? How do you do it with GeoJSON? I thought that the data was inaccessible once imported.

What I had in mind was making the wallColor properties depend on both a building attribute and some user-editable color range (so that you could easily play around with different color schemes).

On Sat, Apr 6, 2013 at 12:17 PM, Jan Marsch notifications@github.comwrote:

In case of GeoJSON you could already do that. Do you have a more specific use case, i.e. creating an editor?

— Reply to this email directly or view it on GitHubhttps://github.com/kekscom/osmbuildings/issues/26#issuecomment-16002238 .

kekscom commented 11 years ago

It is inacessible indeed :-) Workaround would be storing it in your context before injecting to OSM Buildings and re-injecting it after a change. I'll consider making it accessible. Thats why I asked for a use case. Putting it on my list.

bennlich commented 11 years ago

I'm thinking this should eventually involve some kind of animation from old values -> new values. What do you think?

kekscom commented 11 years ago

:+1:

dkniffin commented 11 years ago

+1 to this. It'd be awesome to be able to import some buildings, and when a user pans around the map, load some more data from the server and add that to the data object.

kekscom commented 11 years ago

@oddityoverseer13 like mixing your very own data set with a common buildings layer?

dkniffin commented 11 years ago

well, not really. I'm using a custom node.js server to send geojson about the buildings back to the client. What'd I'd like to be able to do is when a user pans around, the client requests the new building data from the server, and adds it to the geojson for the osm buildings layer.

kekscom commented 11 years ago

Ok, then its alredy done with latest commits to master :-) Just dont have docs yet, but we may work that out. Client will replace tags {n} {e} {s} {e} in a given URL in order to create a bounding box. Server needs to handle that, i.e. in PostGIS like SELECT height, ST_AsText(the_geom) FROM buildings WHERE the_geom && ST_SetSRID(ST_MakeBox2D(ST_Point({w}, {s}), ST_Point({e}, {n})), 4326) For cross site requests, CORS needs to be enabled. Let me know your progress!

dkniffin commented 11 years ago

I'm not sure I understand. So, lets say I have some geoJSON I want to add to a osmbuildings layer (var osmb). How would I go about adding it?

kekscom commented 11 years ago

I assume, your Node.js backend is serving GeoJSON and you are able to parametrize that. Basically the client calls an URL of which n,w,s,e (bounding box tags are replaced by client). Schematic call: new L.BuildingsLayer().addTo(map).load('http://yournodeserver.com/?format=geojson&w={w}&s={s}&e={e}&n={n}');. Then you need to process those parameters in Node and prepare the date accordingly.

In my case, I'm using CartoDB which's query is more complicated, but does exactly this:

var map = new L.Map('map').setView([52.50557, 13.33451], 17);
new L.TileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpg', { maxZoom: 18 }).addTo(map);
var osmb = new L.BuildingsLayer().addTo(map).load('http://osmbuildings.cartodb.com/api/v2/sql?q=' + ('SELECT cartodb_id AS id, height, ST_AsText(ST_MakePolygon(ST_ExteriorRing(ST_GeometryN(the_geom, 1)))) AS the_geom FROM buildings WHERE the_geom %26%26 ST_SetSRID(ST_MakeBox2D(ST_Point({w}, {s}), ST_Point({e}, {n})), 4326)') + '&format=geojson');
kekscom commented 11 years ago

Server-less version is now official. You could go with suggested solution noted above. The original comment, making buildings interactive is still on my list.

bennlich commented 11 years ago

Hey, Jan. I'm up for working a bit on interactive building data. (I need to be able to animate building color.)

Have you started this yet? Are you thinking of exposing some methods to edit / redraw properties of cached data?

kekscom commented 11 years ago

Hi Benny, nothing is started yet.

My thoughts about this are: buildings will need to be act on hover and click. How the reaction looks, be it just an event or something on the buildings changes, that's not clear yet. But once that mechanism is in place, it could also act on a chosen building programmatically.

Things you need to consider:

What I would offer is:

The above things are ok performance wise, it's the animation which probably kills it.

I need to know a bit more about your application and you will have a bit of work ahead as I can't provide all of that right now. But I'm here to help.

dkniffin commented 11 years ago

@bennlich Let me know if you need help with this. It's something I would really like to see happen. I am working on an RTS game and clicking and "selecting" buildings is a must for me. I can probably handle the "selection" separately, but I do need some sort of click functionality. I recently talked to Jan about doing this myself, but I'm a bit busy with other things atm, so I don't have much time to think about how to do it. But I am willing to help if someone gives me something to do :smile:

kekscom commented 11 years ago

I will jump in and help at some point! Just busy for the next week.