[OSGeo-Discuss] Interesting Error with Java Restful Web Service

Jeff Goyette jgoyette.jg at gmail.com
Tue May 13 15:42:47 PDT 2014


Hi,

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:

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).

Layer name: OGRGeoJSON
Geometry: Polygon
Feature Count: 1
Extent: (-124.301856, 42.614771) - (-124.280787, 42.643928)
Layer SRS WKT:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        TOWGS84[0,0,0,0,0,0,0],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0,
        AUTHORITY["EPSG","8901"]],
    UNIT["degree",0.0174532925199433,
        AUTHORITY["EPSG","9108"]],
    AUTHORITY["EPSG","4326"]]

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.

"crs": { "type": "name", "properties": { "name":
"urn:ogc:def:crs:OGC:1.3:CRS84" } },

When it is read into the webservice, I print it out again to make sure it
works fine. The above one works as expected.

When using another geojson that did not have the projection specified, it
prints out this from command line:

Layer name: OGRGeoJSON
Geometry: Polygon
Feature Count: 1
Extent: (-124.230850, 42.614800) - (-124.136382, 42.693174)
Layer SRS WKT:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0,
        AUTHORITY["EPSG","8901"]],
    UNIT["degree",0.0174532925199433,
        AUTHORITY["EPSG","9122"]],
    AUTHORITY["EPSG","4326"]]

However, when the webservice makes the call to ogrinfo, it does not read in
correctly. It instead reads this:

Layer name: OGRGeoJSON
Geometry: Polygon
Feature Count: 1
Extent: (-124.230850, 42.614800) - (-124.136382, 42.693174)
Layer SRS WKT:
(unknown)

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:

            String line;
            Process p = Runtime.getRuntime().exec(
                    "C:\\Program Files (x86)\\QGIS
Valmiera\\bin\\ogrinfo.exe -al -geom=no "
                            + fileName);
            System.out.println(fileName);
            BufferedReader in = new BufferedReader(new InputStreamReader(
                    p.getInputStream()));
            while ((line = in.readLine()) != null) {
                outPut.add(line);
                System.out.println(line);
            }
            in.close();

I hope that someone could help me with this.

Regards,

Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/discuss/attachments/20140513/7486c837/attachment-0002.html>


More information about the Discuss mailing list