MapBox ability to detect if coordinates is on a body of water?

旧巷老猫 提交于 2019-12-11 05:08:47

问题


First of all, MapBox allows downloading off-line region. Well, downloading off-line region for the Pacific ocean doesn't really make sense. I was sent a ticket coming from the QA department to at least prevent user from ever downloading anything when the coordinates requested is on a body of water (doesn't really matter if it is a river, waterfalls, sewage what not). I have to prevent user accidentally downloading off-line regions that mostly composed of body of water (mostly oceans or seas).

I am creating an application for a client whose user base are seafarers and downloading off-line region can be costly. So my question is MapBox capable of detecting this without me ever using this hack?

Thanks!


回答1:


You can query the map tiles directly without the need to make an API call. An example doing this is if you want to check the users center view port point.

LatLng center = mapboxMap.getCameraPosition().target;
final PointF pixel = mapboxMap.getProjection().toScreenLocation(center);
List<Feature> features = mapboxMap.queryRenderedFeatures(pixel, "water");

This will return a list of features with at least a size of 1 if the users currently looking at water, otherwise, it will have a size of 0.

Note that you can also do this considering the entire viewport area or any bounding box region for that matter.



来源:https://stackoverflow.com/questions/42708403/mapbox-ability-to-detect-if-coordinates-is-on-a-body-of-water

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!