After seeing a recent video by the Google Devs I decided to do a regional map of the UK. There were a couple of possibilities mentioned on this site that I've since had to dismiss*
So I ended up using this site (example page of data downloads): http://mapit.mysociety.org/area/11804.html
Notice the GeoJSON download as the third link down? Its about a 1Mb file size. When I first tried using it with my map:
function initMap(){
var ukc = new google.maps.LatLng(54.8, -4.6);
var mapOptions = {
zoom: 5,
center: ukc
};
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
map.data.loadGeoJson('http://local.mapsite.com:8080/app/jsondata/eastern.json');
}
$(document).ready(function(){
initMap();
});
I got the above error: Uncaught InvalidValueError: not a Feature or FeatureCollection
Fix Attempt 1 - Google it
Googling the error came back with nothing useful.
Fix Attempt 2 - Shrink it
I thought maybe it was the sheer size of the beast so I shrank it using mapshaper.org to a more manageable 10K. Still no luck!
Fix Attempt 3 - Lint it
Maybe my GeoJSON was badly formatted? But how could it be considering it was right there working on mapit.org but I found this wonderful site for linting GeoJSON data: http://geojsonlint.com/ - The linting worked! Apparently the GeoJSON worked so well that it drew my polygon of East Anglia on the UK in all its glory (note geojsonlint uses OpenStreetMap). But still No Luck
Fix Attempt 4 - TopoJson
Hoping I could combine the regions and compress at the same time I thought desperately that topojson would work. I tried - I still got that same error. Here's a link to my topojson file shared on Google Drive: someregions.json No luck.
Fix Attempt 5 - Add Feature code to start of JSON
The current GeoJSON file starts
{"bbox":[-0.745702,51.448473,1.767999,52.98991],"type":"GeometryCollection","geometries":...
I added:
{"type": "Feature", "bbox":[-0.745702,51.448473,1.767999,52.98991],"type":"GeometryCollection","geometries":
Fix Attempt 6
Retry different regions as they donm't contain the bbox parameter near the start but simply start
{ "type": "Polygon", "coordinates": [ [ [ -3.155785, 53.427385 ], [ -3.151533, 53.427328 ], [...
Still no luck.
In (Failed) Conclusion
Even though I proved my file was small enough, linted and worked elsewhere I still got those infuriating error messages from the console when attempting to put them on my map.
Uncaught InvalidValueError: not a Feature or FeatureCollection
Here is my shrunk GeoJSON file publically shared via GDrive: https://drive.google.com/file/d/0B42Aec8RKcHtNVNZZUxqV0Y5Rkk/edit?usp=sharing
My next attempts will involve topojson to compress all regions into one with internal borders but I wanted to check here first to see if anyone knows what my problem could be? Because that may be another few hours of futile energy wasted.
* Attempting to use Ordanance Survey data failed as they provided SHD data and not SHP as stated in a previous question on the subject. So I couldn't convert it into GeoJSON using ogr2ogr.
The specification for GeoJSON can be found at http://geojson.org/geojson-spec.html
Relevant (though experimental) Google Maps API documentation can be found at https://developers.google.com/maps/documentation/javascript/3.exp/reference#Data
So it looks like for GeoJSON to be acceptable by Google Maps, you need to wrap a Polygon (or similar) returned by MapIt in a Feature or FeatureCollection, here's an example for bermuda-triangle:
{ "type": "FeatureCollection",
"features": [
{ "type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates":
[
[
[-80.190262,25.774252],
[-66.118292,18.466465],
[-64.75737,32.321384],
[-80.190262,25.774252]
]
]
}
}
]
}
for the data provided by http://mapit.mysociety.org/area/11804.html it has to be:
{ "type": "FeatureCollection",
"features": [
{ "type": "Feature",
"geometry": /** paste here the complete output of
http://mapit.mysociety.org/area/11804.geojson **/
}
]
}
I had the same problem (or at least similar) and solved it by introducing one extra step.
Origin of the data:
My semantic Network delivers on a first round request the data about the caves in Southern France in GeoJSON format. This is directly imported via:
map.data.loadGeoJson(theUrl);
As we might want to work independent of the semantic network with these data (the app is a thick client) the caves are locally stored via jStorage.
Iterating of the features of the map and storing these objects directly in jStorage failed because of circular references.
I made a handcrafted routine (not generic enough but suiting the purpose) to transform the map.data.Feature into a javascript object that could be stored.
When getting the data from the store:
var cave = $.jStorage.get(key);
map.data.addGeoJson(cave);
throws the Uncaught InvalidValueError: not a Feature or FeatureCollection error.
But:
var geojson = JSON.parse(cave);
map.data.addGeoJson(geojson);
Works fine.
My interpretation is that the function addGeoJson needs a javascript object and not a string.
Sample geoJson (the orignal "cave") value:
{ "type": "Feature", "geometry": {"type": "Point", "coordinates": [5.368743302306143, 44.0421921072459]},"id": "84.MON.014", "properties": {"nom": "Aven du Grand Guérin", "nid": "7b4703-f387f6f544-0750e59f441be7bb30a7e097c5d725f7", "nature": "Aven", "nodeTime": 1400743203325, "dataId": "5b66137c-1461fdfe5ca-f528764d624db129b32c21fbca0cb8d6", "status": 1}}
If you are looking to load the data to a JavaScript variable then use this
var map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
var data = map.data.loadGeoJson("GeoJSONfilename.geojson");
googleMap is the div id where you want your map to be presented, and GeoJSONfilename.geojson where you saved your GeoJSON data.
I had the same error, but the problem was something very simple. On my GeoJSON, instead of
"type": "Feature"
I had
"type": "feature"
(note the lowercase 'f')
Once I fixed this, the error was gone.
I had the same error message. My .json file missed one line of code on line 2:
"type": "FeatureCollection",
Before I had in my .json-file:
{
"features": [
{
"type": "Feature",
"properties": {
"stroke": "#ECD911",
"stroke-width": 5
},
"geometry": {
"type": "LineString",
"coordinates": [
[13.295141458511353, 52.5069227387063],
[13.295291662216187, 52.50721006978328],
[13.29544186592102, 52.507471278223285]
]
}
}
]
}
It fixed it for me with:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"stroke": "#ECD911",
"stroke-width": 5
},
"geometry": {
"type": "LineString",
"coordinates": [
[13.295141458511353, 52.5069227387063],
[13.295291662216187, 52.50721006978328],
[13.29544186592102, 52.507471278223285]
]
}
}
]
}
Related
I have followed the Postman tutorial for the model derivative API, specifically for extracting metadata. I used a .dxf file, since I want to know if it is possible to retrieve perimeter, length/width properties based off the file.
I received a 200 response and it gave me a massive list of objects w/ their respective objectid's. Basically I got back a ton of these:
{
"objectid": 253,
"name": "Line [108]",
"externalId": "108",
"properties": {
"3D Visualization ": {
"Material": "ByLayer"
},
"General": {
"Color": "ByLayer",
"Handle": "108",
"Layer": "color#000000ff",
"Linetype": "BYLAYER",
"Linetype scale": "1.000",
"Lineweight": "ByLayer",
"Name ": "Line",
"Plot style": "ByColor",
"Thickness": "0.000 mm",
"Transparency": "ByLayer"
},
"Geometry": {
"Angle": "192.931 deg",
"Length": "0.088 mm"
}
}
}
The .dxf file I tested was as simple as possible and it looks like this image:
How can I retrieve the perimeter of this image? Is it possible to retrieve other specific geometric properties that I specify?
How can I know what part of the .dxf file each objectid is referring to?
Although it looks simple, the polyline (?) is probably being tessellated, resulting in a large number of small lines. Have you tried the original DWG file? Can you try that with viewer.autodesk.com?
As per the graphhopper 0.9 release, it says
A new graph change API to change road speed and access properties, #845. Can be applied before preprocessing or per-request.
how do i use it, can someone point me to the documentation with example ?
thanks for your support
Indeed there is no good documentation at the moment. Have a look into the tests:
Disable speed mode - set prepare.ch.weightings=no in the config.properties
Create a GeoJSON where e.g. you want to change the access properties to false (blocking):
{
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [1.521692, 42.522969]
},
"properties": {
"vehicles": ["car"],
"access": false
}
}]
}
Then POST this as json to the /change endpoint.
Please note that in 0.9.0
for geometry type only Point, MultiPoint and LineString are supported.
for the properties only access (Boolean) and speed (Double) are supported that can be applied to multiple vehicles (but only in both directions).
You can also use the Java equivalent.
Please see this issue to improve the documentation.
I have an SAPUI5 app that needs to plot spots on a GeoMap control. It works fine, so long as I use HEREMaps as the provider. However, the company would like me to use Google Maps. I can't find any information out there about how to set up the MapProvider for the GeoMap control to use Google Maps.
Here is (essentially) my GeoMap control:
<vk:content>
<vk:ContainerContent title="Map" icon="sap-icon://choropleth-chart">
<vk:content>
<vbm:GeoMap id="GeoMap" width="100%" height="100%">
<vbm:vos>
<vbm:Spots
click="onClickItem"
contextMenu="onContextMenuItem"
id="caseTimeMapSpots"
items="{path: '/CaseEvents/results'}"
posChangeable="true"
scaleChangeable="true"
>
<vbm:items>
<vbm:Spot
id="Spot"
position="{Longitude};{Latitude};0"
tooltip="{EventName} - {path: 'EventDatetime', formatter: '.formatDate'} {path: 'EventDatetime', formatter: '.formatTime'}"
type="Warning"
click="onClickSpot"
contextMenu="onContextMenuSpot"
text="{EventName}"
scale="{path: 'DeleteInd', formatter: '.formatScale'}"
/>
</vbm:items>
</vbm:Spots>
</vbm:vos>
</vbm:GeoMap>
</vk:content>
</vk:ContainerContent>
</vk:content>
And here is where I set the MapProvider in my controller:
var oGeoMap = this.getView().byId("GeoMap");
var oMapConfig = {
"MapProvider": [{
"name": "HEREMAPS",
"type": "",
"description": "",
"tileX": "256",
"tileY": "256",
"maxLOD": "20",
"copyright": "Tiles Courtesy of HERE Maps",
"Source": [
{
"id": "s1",
"url": "https://1.base.maps.cit.api.here.com/maptile/2.1/maptile/newest/normal.day/{LOD}/{X}/{Y}/256/png8?app_id=XXX"
},
{
"id": "s2",
"url": "https://2.base.maps.cit.api.here.com/maptile/2.1/maptile/newest/normal.day/{LOD}/{X}/{Y}/256/png8?app_id=XXX"
}
]
}],
"MapLayerStacks": [{
"name": "DEFAULT",
"MapLayer": {
"name": "layer1",
"refMapProvider": "HEREMAPS",
"opacity": "1.0",
"colBkgnd": "RGB(255,255,255)"
}
}]
};
oGeoMap.setMapConfiguration(oMapConfig);
oGeoMap.setRefMapLayerStack("DEFAULT");
oGeoMap.setInitialZoom(13);
oGeoMap.setInitialPosition("-97.57;35.57;0");
Has anyone done this using Google Maps? How is the MapProvider set up?
Thanks.
Update
So I am finaly able to wrap this up. There is an official way to access googles map tiles directly using the Tiles API.
Following the guide in the link you could configure the MapConfig seen below with the URL from the Tiles API.
But this API is not available without a paid plan! (This plan runs about 10x as expensive then the JS API usage though) Due to this I will not follow up on this any further.
I am sorry this I still have not figured this out to the extend I'd like to. The following configuration is the most stripped down version that does the trick. The point here is that you need the url to directly get the map tiles. With X and Y specifying the tiles and {LOD} the level of detail. These parameters don't have to be replaced but will be set by the GeoMap control during run time.
The main reason I have not yet posted this is that - while it is working on a technical level - everything I have read so far indicates that accessing the tiles directly is against the ToS of Google Maps. So while it is working for fiddling around I would not use that in a production environment! Currently I am trying to find a way to clarify if there is something in the licensing to enable this use or if I am SOL.
Unfortunately the official API does not provide a way to request specific map tiles. Another way to figure this out would be to see if SAP can/does provide a different MapProvider implementation.
var oMapConfig = {
"MapProvider": [{
"name": "GMAP",
"Source": [{
"id": "s1",
"url": "https://mt.google.com/vt/x={X}&y={Y}&z={LOD}"
}]
}],
"MapLayerStacks": [{
"name": "DEFAULT",
"MapLayer": {
"name": "layer1",
"refMapProvider": "GMAP",
"opacity": "1",
"colBkgnd": "RGB(255,255,255)"
}
}]
};
Can I use coordinates [Lat,Long, Elevation, Time] in a GeoJSON file so that file can be used by any other application?
{ "type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[102.0, 0.0,805,"22-08-2016 13:04:04"],
[103.0, 1.0,806,"22-08-2016 13:05:04"],
[104.0, 0.0,804,"22-08-2016 13:06:00"],
[105.0, 1.0,808,"22-08-2016 13:07:40"]]
},
"properties": {
"prop0": "value0",
"prop1": 0.0
}
}
// "Using elevation and time in coordinate array elevation as numeric and time in string format
This would be the geoJSON specification.
As they say in the section about extending geoJSON you can extend to add foreign members, but anything that alters the structure of the already defined types is referred to as versioning geoJSON, and as such that kind of object should not be called a geoJSON.
You can check the specifications they define for a position array.
TL;DR you can, but it wont be a geoJSON anymore and parsers are not guaranteed to work with it.
I've textured a cube in blender 2.6. I assigned a color map from file cube.png to the cube. I assigned a normal map from file bump.png to the cube. I set the normal map to be a normal map and to influence normals. Blender displays the normal mapping correctly. I've then used fbx-conv 0.01 with option -o g3dj to get a readable file. The only warning I got was the RrSs thingie, which afaik can be safely ignored. I then opened the file to inspect the result. The texture structure does not reflect the normal map:
"materials": [
{
"id": "Material",
"diffuse": [ 0.800000, 0.800000, 0.800000],
"emissive": [ 0.800000, 0.800000, 0.800000]
},
{
"id": "Material__bump_png",
"diffuse": [ 0.800000, 0.800000, 0.800000],
"emissive": [ 0.800000, 0.800000, 0.800000],
"textures": [
{
"id": "bump_png",
"filename": "bump.png",
"type": "DIFFUSE"
}
]
}
],
So basically it exports the last texture of the texture stack, and it exports it with standard settings, not as a diffuse map.
What do I have to do (in Blender settings, I suppose) to have normal mapping exported correctly using fbx-conv?
3D Model with Diffuse AND Normalmap texture suggests that normal map export should be supported. probably I am doing something wrong in blender?
thanks a lot
Wolfgang
We do have problems with the exported Models from Blender as well. And I have never seen the fbx-conv exporting the normal map correctly (probably, cause I am doing smth. wrong)
a solution would be to convert the fbx into g3dj, put in the normal map manually.
},
{
"id": "stone_phong",
"diffuse": [ 1.000000, 1.000000, 1.000000],
"specular": [ 0.204000, 0.163487, 0.079152],
"textures": [
{
"id": "file5",
"filename": "rock_diff.png",
"type": "DIFFUSE"
},
{
"id": "stone_norm",
"filename": "rock_norm.png",
"type": "NORMAL"
}
]
},
as described in the tutorial from xoppa. And use g3dj for testing. afaik fbx-conv can convert g3dj into g3db as well.
The disappointing thing you'll figure out, is that it still does not use the normal maps in the shader.
[Edit:] A closer look in the G3ModelLoader tells me that instead of NORMAPMAP you have to use NORMAL to make the loader associate the normal texture attribute as such. I corrected that in the g3dj example above