<div dir="ltr"><div><div><div><div><div><div><div><div>Hi,<br><br></div>I have been browsing through the archives to see if my question has come up before. I did not see it so here it goes:<br><br></div>I am making a restful webservice in Java to validate geojson files. Now, long story short it does this for shp as well ,and I am reusing part of it to do geojson. When I run ogrinfo -al -geom=no with my geojson file in command line, it gives me everything I need (printout below).<br>
<br>Layer name: OGRGeoJSON<br>Geometry: Polygon<br>Feature Count: 1<br>Extent: (-124.301856, 42.614771) - (-124.280787, 42.643928)<br>Layer SRS WKT:<br>GEOGCS["WGS 84",<br> DATUM["WGS_1984",<br> SPHEROID["WGS 84",6378137,298.257223563,<br>
AUTHORITY["EPSG","7030"]],<br> TOWGS84[0,0,0,0,0,0,0],<br> AUTHORITY["EPSG","6326"]],<br> PRIMEM["Greenwich",0,<br> AUTHORITY["EPSG","8901"]],<br>
UNIT["degree",0.0174532925199433,<br> AUTHORITY["EPSG","9108"]],<br> AUTHORITY["EPSG","4326"]]<br><br></div>The point of interest is the Layer SRS WKT. This printout is from a geojson file converted over with ogr2ogr specifying the projection. It has this additional line in the actual geojson file itself.<br>
<br>"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },<br><br></div>When it is read into the webservice, I print it out again to make sure it works fine. The above one works as expected.<br>
<br></div>When using another geojson that did not have the projection specified, it prints out this from command line:<br><br>Layer name: OGRGeoJSON<br>Geometry: Polygon<br>Feature Count: 1<br>Extent: (-124.230850, 42.614800) - (-124.136382, 42.693174)<br>
Layer SRS WKT:<br>GEOGCS["WGS 84",<br> DATUM["WGS_1984",<br> SPHEROID["WGS 84",6378137,298.257223563,<br> AUTHORITY["EPSG","7030"]],<br> AUTHORITY["EPSG","6326"]],<br>
PRIMEM["Greenwich",0,<br> AUTHORITY["EPSG","8901"]],<br> UNIT["degree",0.0174532925199433,<br> AUTHORITY["EPSG","9122"]],<br> AUTHORITY["EPSG","4326"]]<br>
<br></div>However, when the webservice makes the call to ogrinfo, it does not read in correctly. It instead reads this:<br><br>Layer name: OGRGeoJSON<br>Geometry: Polygon<br>Feature Count: 1<br>Extent: (-124.230850, 42.614800) - (-124.136382, 42.693174)<br>
Layer SRS WKT:<br>(unknown)<br><br></div>What would cause it to generate a different printout when everything else is otherwise the same? I am running it through the same ogrinfo.exe with the same flags. Is it the fact that I specified the projection in the one file? My Java code for reading the file in and printing it out is below:<br>
<br> String line;<br> Process p = Runtime.getRuntime().exec(<br> "C:\\Program Files (x86)\\QGIS Valmiera\\bin\\ogrinfo.exe -al -geom=no "<br> + fileName);<br>
System.out.println(fileName);<br> BufferedReader in = new BufferedReader(new InputStreamReader(<br> p.getInputStream()));<br> while ((line = in.readLine()) != null) {<br>
outPut.add(line);<br> System.out.println(line);<br> }<br> in.close();<br><br></div>I hope that someone could help me with this.<br><br>Regards,<br><br>Jeff<br></div>