3

I have a use case in which I need to parse the XML generated by an ArcGIS server, then push that data to another API. The ArcGIS server sits behind the firewall at our customer's site and exposes a REST through which we can query the database. The REST URL looks something like this:

http://SERVER_NAME/arcgis/rest/services/APP_NAME/MapServer

I plan on stepping through the DOM and extract the records in Java (probably using Xerces). All the fields except the geometry fields are pretty straightforward. The geometry fields are defined as type esriFieldTypeGeometry with the data being stored as base64 binary string. My question is: how do I parse the binary data in Java and convert it to a set of coordinates?

Here is an extract of the XML:

<esri:Workspace xmlns:esri='http://www.esri.com/schemas/ArcGIS/10.1'
    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
    xmlns:xs='http://www.w3.org/2001/XMLSchema'>
    <WorkspaceDefinition xsi:type='esri:WorkspaceDefinition'>
        ...
    </WorkspaceDefinition>
    <WorkspaceData xsi:type='esri:WorkspaceData'>
        <DatasetData xsi:type='esri:TableData'>
            ...
            <DatasetType>esriDTFeatureClass</DatasetType>
            <Data xsi:type='esri:RecordSet'>
                <Fields xsi:type='esri:Fields'>
                    <FieldArray xsi:type='esri:ArrayOfField'>
                        ...
                        <Field xsi:type='esri:Field'>
                            <Name>SHAPE</Name>
                            <Type>esriFieldTypeGeometry</Type>
                            <IsNullable>true</IsNullable>
                            <Length>4</Length>
                            <Precision>0</Precision>
                            <Scale>0</Scale>
                            <Required>true</Required>
                            <DomainFixed>true</DomainFixed>
                            <GeometryDef xsi:type='esri:GeometryDef'>
                                <AvgNumPoints>0</AvgNumPoints>
                                <GeometryType>esriGeometryPoint</GeometryType>
                                <HasM>false</HasM>
                                <HasZ>false</HasZ>
                                <SpatialReference xsi:type='esri:ProjectedCoordinateSystem'>
                                    <WKT>PROJCS[...]</WKT>
                                    <XOrigin>-20037700</XOrigin>
                                    <YOrigin>-30241100</YOrigin>
                                    <XYScale>10000</XYScale>
                                    <ZOrigin>0</ZOrigin>
                                    <ZScale>1</ZScale>
                                    <MOrigin>0</MOrigin>
                                    <MScale>1</MScale>
                                    <XYTolerance>0.001</XYTolerance>
                                    <ZTolerance>0.001</ZTolerance>
                                    <MTolerance>0.001</MTolerance>
                                    <HighPrecision>true</HighPrecision>
                                    <WKID>102656</WKID>
                                    <LatestWKID>2234</LatestWKID>
                                </SpatialReference>
                                <GridSize0>3575.0162431554045</GridSize0>
                            </GeometryDef>
                            <AliasName>SHAPE</AliasName>
                            <ModelName>System-maintained Geometry for a feature</ModelName>
                        </Field>
                    </FieldArray>
                </Fields>
                <Records xsi:type='esri:ArrayOfRecord'>
                    <Record xsi:type='esri:Record'>
                        <Values xsi:type='esri:ArrayOfValue'>
                            ...
                            <Value xsi:type='esri:PointB'>
                                <Bytes>AQAAAMAnD4uRGzJBAFYObYdpJ0E=
                                </Bytes>
                            </Value>
                        </Values>
                    </Record>
                </Records>
            </Data>
        </DatasetData>
    </WorkspaceData>
</esri:Workspace>

Thanks in advance for any suggestions you guys can give.

  • In addition to PointB data, I also have to work with PolylineB and PolygonB data. – bluecollarcoder May 30 '13 at 21:48
1

My question is: how do I parse the binary data in Java and convert it to a set of coordinates?

Tutorial

URL xmlURL = new URL("http://www.cse.lk/listedcompanies/overview.htm?d-16544-e=3&6578706f7274=1");
InputStream xml = xmlURL.openStream();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(xml);
xml.close();
  • The question is not about how to parse XML. The question is how to handle the binary base64 coordinate data when parsing the ESRI XML. This is the node in question: <Value xsi:type='esri:PointB'> <Bytes>AQAAAMAnD4uRGzJBAFYObYdpJ0E=</Bytes> </Value> – bluecollarcoder Jun 7 '13 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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