2

I'm calling the geo:centroid WPS process from Geoserver. If I set the output type to "application/json" the returned values has only 4 digits after the dot (e.g xx.xxxx), but if I set the output type to "text/xml" the returned values has more digits after the dot (e.g xx.xxxxxxxxxxxxxxx). My question is how to make the "application/json" returned values have more precisions (more digits after the dot).

Here is an example:

1- application/json

<?xml version="1.0" encoding="UTF-8"?>
<wps:Execute version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/wps/1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wcs="http://www.opengis.net/wcs/1.1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
  <ows:Identifier>geo:centroid</ows:Identifier>
  <wps:DataInputs>
    <wps:Input>
      <ows:Identifier>geom</ows:Identifier>
      <wps:Data>
        <wps:ComplexData mimeType="application/json">
            <![CDATA[
        {
  "type": "LineString",
  "coordinates": [
    [
      [
        0,
        0
      ],
      [
        10.25124,
        0.257741
      ],
      [
        10.578814,
        10.255447
      ]
    ]
  ]
}
]]>
        </wps:ComplexData>
      </wps:Data>
    </wps:Input>
  </wps:DataInputs>
  <wps:ResponseForm>
    <wps:RawDataOutput mimeType="application/json">
      <ows:Identifier>result</ows:Identifier>
    </wps:RawDataOutput>
  </wps:ResponseForm>
</wps:Execute>

it returns

{
  "type": "Point",
  "coordinates": [
    7.7375,
    2.6609
  ]
}

2- text/xml

<?xml version="1.0" encoding="UTF-8"?>
<wps:Execute version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/wps/1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wcs="http://www.opengis.net/wcs/1.1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
  <ows:Identifier>geo:centroid</ows:Identifier>
  <wps:DataInputs>
    <wps:Input>
      <ows:Identifier>geom</ows:Identifier>
      <wps:Data>
        <wps:ComplexData mimeType="application/json">
            <![CDATA[
        {
  "type": "LineString",
  "coordinates": [
    [
      [
        0,
        0
      ],
      [
        10.25124,
        0.257741
      ],
      [
        10.578814,
        10.255447
      ]
    ]
  ]
}
]]>
        </wps:ComplexData>
      </wps:Data>
    </wps:Input>
  </wps:DataInputs>
  <wps:ResponseForm>
    <wps:RawDataOutput mimeType="text/xml">
      <ows:Identifier>result</ows:Identifier>
    </wps:RawDataOutput>
  </wps:ResponseForm>
</wps:Execute>

it returns

<?xml version="1.0" encoding="UTF-8"?>
<gml:Point xmlns:gml="http://www.opengis.net/gml" srsDimension="2" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sch="http://www.ascc.net/xml/schematron" xmlns:xlink="http://www.w3.org/1999/xlink">
    <gml:pos>
        7.737501114169446 2.6609131596654136
    </gml:pos>
</gml:Point>

3 Answers 3

4

It is possible to define the decimal precision on GeoServer configuration.

Configuration -> Global -> Decimal Precision

2

Geoserver UI

Settings Section -> Global -> Number of decimals -> Enter your desired precision

-1

You need to modify GeoJSONPPIO to make use of the same roundedNumber method as GeoJSONBuilder does.

Usual guidelines apply.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.