Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamic buildings #26

Closed
bennlich opened this issue Apr 5, 2013 · 16 comments
Closed

dynamic buildings #26

bennlich opened this issue Apr 5, 2013 · 16 comments
Milestone

Comments

@bennlich
Copy link

bennlich commented Apr 5, 2013

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
Copy link
Owner

kekscom commented Apr 6, 2013

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

@bennlich
Copy link
Author

bennlich commented Apr 7, 2013

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//issues/26#issuecomment-16002238
.

@kekscom
Copy link
Owner

kekscom commented Apr 9, 2013

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
Copy link
Author

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

@kekscom
Copy link
Owner

kekscom commented Apr 23, 2013

👍

@dkniffin
Copy link

+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
Copy link
Owner

kekscom commented May 30, 2013

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

@dkniffin
Copy link

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
Copy link
Owner

kekscom commented May 31, 2013

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
Copy link

dkniffin commented Jun 3, 2013

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
Copy link
Owner

kekscom commented Jun 3, 2013

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
Copy link
Owner

kekscom commented Jun 18, 2013

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.

@kekscom kekscom closed this as completed Jun 18, 2013
@bennlich
Copy link
Author

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
Copy link
Owner

kekscom commented Jun 26, 2013

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:

  • How do you want to identify a building? building id, geo coordinates, screen coordinates?
  • Changing it means changing the render stream plus a full redraw for each animation frame.
  • You probably also need to track your changes in order to override the raw data cache (reloading OSM data should not overwrite your animation state).

What I would offer is:

  • building events: hover, click
  • possibility to change a building upon that event, just not animated
  • an mechanism to change a building once it is prepared for rendering (just on map move end, on zoom end),
    also not animated

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
Copy link

@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 😄

@kekscom
Copy link
Owner

kekscom commented Jun 28, 2013

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants