Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
    
In addition to PointB data, I also have to work with PolylineB and PolygonB data. –  bluecollarcoder May 30 '13 at 21:48
add comment

1 Answer 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();
share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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