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

Feature Request: Support meters as size unit for points #1121

Open
westnordost opened this issue Nov 30, 2016 · 6 comments
Open

Feature Request: Support meters as size unit for points #1121

westnordost opened this issue Nov 30, 2016 · 6 comments

Comments

@westnordost
Copy link
Contributor

I am trying to show the accuracy radius of a location around the user. Here, I ran into some problems. I think part of it is a bug, part of it is a missing feature probably.

The relevant portion of the style file:

styles:
    location-radius:
        base: points
        blend: overlay
        blend_order: 2
layers:
    streetcomplete_location:
        data: { source: streetcomplete_location }
        draw:
            location-radius:
                collide: false
                color: '#44fd6c3e'
                size: function() { return feature.radius }

and the code

locationLayer.clear();
LngLat pos = new LngLat(location.getLongitude(), location.getLatitude());
int accuracy = (int)(Math.ceil(location.getAccuracy()));

Map<String, String> props = new HashMap<>();
props.put("type", "point");
props.put("radius", ""+accuracy+"m");
locationLayer.addPoint(pos, props);

However, this gives i.e. the error:
styleParam.cpp:184: Invalid size parameter '22m'

If I set a static size in the style definition, I get no error, but it doesn't seem to show at all.

So my guess is that meters as a size unit for points is simply not implemented as there hasn't been a use case for this (until now :-P). At least it is not documented. That Tangram-ES does not report an error if you write size: 50m seems to be a bug then.
In any case, this ticket shall be a feature request to support meters as a unit for points.

Plan B for the use case I have in mind would be to use a circle-polygon for the radius, but I find that rather ugly.

@westnordost
Copy link
Contributor Author

westnordost commented Nov 30, 2016

Perhaps another use case would be tree-nodes. (natural=tree)

@Guillaume227
Copy link

@westnordost : one other posssible workaround would be to use a circular marker together with a js function for the size. That function would back out the size in pixel from the zoom level so it remains constant in meters. I haven't tested that yet.

@westnordost

This comment has been minimized.

@westnordost
Copy link
Contributor Author

Another use case where supporting meters for points would be helpful: Rendering mini-roundabouts and turning circles with some realistic diameter in meters on high zoom levels.

@westnordost
Copy link
Contributor Author

Actually, nevermind my earlier algorithm, much easier is

pixels_per_meter = 2^zoom_level * 256 / (cos(latitude * pi/180) * earth_circumference)

There is also a $meters_per_pixel in the docs, which would make it trivial to workaround this via a javascript function, however in tangram-es it doesn't seem to be supported. See #2138

@westnordost
Copy link
Contributor Author

(Ah, realized that $meters_per_pixel does actually not solve this, because it only changes on full zoom levels changes.)

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

No branches or pull requests

2 participants