Accessing nested properties of a TileSet - mapbox-gl-js

I am trying to access all the features of a specific tileset generated threw MapBoxStudio.
Reading the API doc I guess I should be able to get all the nested parameters from the method :
map.querySourceFeatures(IdOfMyLayer);
However, the output of this is empty.
map.querySourceFeatures('words');
Where 'words' is the ID of the layer I got from map.getStyle().layers
I would expect to get access to the properties of this particular layer.
However, I get an empty result.
Sorry for the noob question but I am missing something crucial here in the way MapBox is working, any help from you would be very much appreciated.

If you are trying to access all the features of a tileset that you created in Studio, you should probably consider a different workflow. By definition, a tileset is a transformation of a dataset optimised for displaying a map, not querying.
If you use a Mapbox dataset rather than a tileset, you can access the whole dataset as a clean GeoJSON object - assuming it's small enough to load into the browser. Alternatively, you could create a GeoJSON by some other means, then upload it.
If querySourceFeature() is returning [], then most likely no features have loaded in the current viewport (yet). Perhaps you need to trigger the call at a later time, when the source data has loaded.

I get it now.
The proper way to retrieve all the features of a dataset is to use the DataSet API:
https://docs.mapbox.com/api/maps/#retrieve-a-dataset
This is what I've done :
$.ajax({
url: 'https://api.mapbox.com/datasets/v1/*****/{dataset_id}/features?limit=50&access_token=********',
type:'GET',
success:function(data){console.log(data)},
error:function(error){console.log('ERROR')}
})
With the {dataset_id} taken from mapboxStudio.
I can limit and store the variable to process the JSON response.
Thanks a lot :)

Related

Should I use neo4j when want to save d3 force graph for next time rendering?

It seems that if I want to render d3 force-directed graph with nodes and links, links pass to the simulation must be in a list of 2-tuple.
This means I need to export the neo4j "connection" back to a list of 2-tuple if I want to render it again next time.
Then, in this case, I couldn't get any benefit from the "native" graph database(quick).
Should I then just probably store the 2-tuple list in MongoDB instead? then I could save time "export the neo4j connection to a list of 2-tuple".
The main reason for using a native graph database is hardly ever pure visualization. But yes, your d3 or any other library you will use , will expect a list of nodes and edges. There are many tools , including ours (Graphileon) that do that conversion of a set of nodes/edges or entire paths for you.
disclosure:I work for graphileon

Mapbox: Is there a way to retrieve all coordinates for a specific feature ID?

I'm building a feature where I need to extract all coordinates of a selecetd road/path in Mapbox when it's clicked on. I've attempted to use the queryRenderedFeatures method, but it seems the result list is fragmented. By "fragmented" I mean that if you have a road or path which is clearly just one long path/road when rendered on the map, it often consists up of 4-5-6 or more features, and you cannot really work out from the feature collection how they're supposed to be connected (in order)
I then tried to use the Tilequery API, but it doesn't return any coordinates for LineStrings.
Is there any API - server or client side - in Mapbox, where you can provide an ID of a feature and retrieve the all coordinates for a road or path?
Thanks in advance :-)
I think you're really asking: "is there a way to access complete LineString features for data in Mapbox's tilesets", to which the answer is, no, not really - other than trying to reassemble them in the way you have tried.
For your own data, you could host it using Mapbox's Datasets, rather than Tilesets.

How to plot a JSON file generated by osrm for route optimization into an OSM map

I am a complete newbie to computation of gps, gis and all these geoinformatical stuff. First I describe my lessons learned to arrive at gps data. You can skip this and go to the last two paragraphs where I explain my problem with osrm and how to map a route onto an OSM map via qgis or similar tools.
I tried to do some route optimization for a bunch of addresses to support my son's paper deliverer job. I was able to generate a list of gps data by using the Nomatim engine that is available via geopy.geocoders. It's kind of a Travelling Salesman problem (TSP).
By using geopy's distance calculator and the or-tools from Google to Generate a shortest list recommendation. That worked well but it was only a TSP solution for air line :-(.
Then I was looking for route optimization toolkits but i struggled to get one for free. I thought osrm could be the right tool. I followed the descriptions given at Github, see here. I was able to generate a JSON file - at least I supposed that it's kind of a JSON file. But I was unable to project this back onto a map in QGis or any online tool from OSM. Can anyone help me?
The file with such JSON-like formatting:
{"code":"Ok","waypoints":[{"hint":"Jh4BgEUzI4BhAAAACwAAAKIAAABZAAAAkLAjQgpyikBay4dCWsuHQmEAAAALAAAAogAAAFkAAAArAAAAxwB4AARI3AI3AXgAWEbcAgIADwXVhXd1","location":...
Due to privacy issues I cannot post it here with any locations. Sorry for this. But does anyone have kind of a recipe / step-by-step guide what I need to do to plot it? I even have no idea how to "open" a map within qgis. You need to do this as kind of a database but this is totally new for me. I would prefer to work with an easier method to plot it.
Thanks in advance for any help.
Please follow the API documentation here. From that documentation
hint Unique internal identifier of the segment (ephemeral, not
constant over data updates) This can be used on subsequent request to
significantly speed up the query and to connect multiple services.
E.g. you can use the hint value obtained by the nearest query as hint
values for route inputs.
You can get the geometry in many ways. Widely GeoJSON is being used by developers. OSRM returns a very clean GeoJSON which can easily be used with Leaflet, Mapbox or other Map APIs. You need to send steps parameter true to get the full step by step direction. You can get the each segments of steps in legs. So call the GeoJSON within the geometries of every legs with loop. You can also get the geometry without passing the steps parameter true. For that you will get full geometry in a single GeoJSON within the routes property.

How to retrieve data from Parse

Using the parse how to retrieve the data to the table view controller if multiple objects are present.
I tried using the query where receptionist equal to current user.
And I tried find objects in background and append it to an array.
But the problem is all the object values appending to the same array.
Read through the Parse IOS Developer's Guide. It has the information & explanations you need to do this.
http://parseplatform.org/docs/ios/guide/
Also, what you're asking really isn't too clear. Try to specify what specific issues you are having along with posting your actual code next time.

MarkLogic "XDMP-FRAGTOOLARGE" error while storing 200MB+ File using REST

When i try to store a 200MB+ xml file to marklogic using REST it gives the following error "XDMP-FRAGTOOLARGE: Fragment of /testdata/upload/submit.xml too large for in-memory storage".
I have tried the Fragment Roots and Fragment Parents option but still gets the same error.
But when i store the file without '.xml' extension in uri. it saves the file but not Xquery operations can be performed on it.
MarkLogic won't be able to derive the mime from the uri without extension. It will then fall back to storing it as binary.
I think that if you would use xdmp:document-load from QConsole, you might be able to load it correctly, as that will not try to hold the entire document in memory first. It won't help you much though, you will likely hit the same error elsewhere. The REST api will have to pass it through in memory, so that won't work like this.
You could raise memory settings in the Admin UI, but you are generally better off by splitting your input. MarkLogic Content Pump (MLCP) will allow you to do so using the aggregate_record options. That will split the file into smaller pieces based on a particular element, and store these as separate documents inside MarkLogic.
HTH!