mapbox / mapbox-unity-sdk

Mapbox Unity SDK - https://www.mapbox.com/unity/
Other
727 stars 210 forks source link

How to get access to GeoJSON data of a feature? #1773

Open dylan-infinitus opened 3 years ago

dylan-infinitus commented 3 years ago

Hello - is there a way to simply grab all feature points in the order defined by their dataset?

i.e. whenever I try to grab all my feature points to do further work with, I end up with a list similar to PointA, PointZ, PointB etc depending on the tile they are attached to.

My apologies if I've overlooked anything. Any help is much appreciated!

Update

After attacking the SDK from multiple angles, I realised the data I am trying to access is already located within the feature GeoJSON. How can I access this data for features in the map I am currently viewing?

I have tried creating web requests to fetch the GeoJSON data from the features, although this returns the entire feature rather than the parts currently in-view on the map. This also isn't very practical as I would need to write this code for every map instance.

I checked out #1300 - although it seems the answer points to the feature properties rather than GeoJSON data.

There must be something I'm missing!

brnkhy commented 3 years ago

Hey @iamDJB! I'm not sure if I understand your question, are you trying to get vertex positions (points) of features or the geojson of feature? If you are planning to do custom visualizations or something, you shouldn't need geojson I guess?

although this returns the entire feature rather than the parts currently in-view on the map. that sounds like a normal behaviour to me. Features get cut at tile edges but they are not getting cut for camera frustum.

dylan-infinitus commented 3 years ago

Hey @brnkhy, thanks for getting back to my query. My bad for not explaining well enough - we ended up skipping this step in our process for a later date.

are you trying to get vertex positions (points) of features or the geojson of feature? We are trying to grab the vertex positions (points). Grabbing the geojson was an attempt at getting these in the correct order.

Essentially, we are trying to access the points in the order given to mapbox via our dataset. In other words; grabbing the points before they are split into the tiles.

image

The above image is a very quick representation of the issue.

We already have a database with our data and we are using mapbox to visualise these points. To resolve this issue, we have decided to add further functionality to our database system which allows us to pull the points within a given range (i.e. what mapbox is doing to place feature points).

However, if there is a way to directly fetch the feature points in their correct order (rather than getting feature points within the tiles) then this might speed up our process.

Our chosen method (updating our database) will allow us to avoid the problem.

I hope this explanation is clearer than before.

Thanks again.

brnkhy commented 3 years ago

@iamDJB I don't think there's an easy way really, cutting polygons into smaller chunks per tile is pretty much the core of the vector system. A few ideas on top of my head though;

I think, if possible, second one might worth giving a shot but of course it all depends on your data/dataset. Is it too big? can you add a property to those points? export with that etc etc.

Hope that helps!