Best way to parse and construct Geometry POINT, LINESTRING, POLYGON string from database?

2814
1
Jump to solution
10-13-2016 08:44 PM
BatbayarBazarragchaa
New Contributor III

Point, Line, Polygons are stored in shape field of database like following and I want to parse and construct a Geometry or at least parse a decimal degree string which can be used for CoordinateConversion.decimalDegreesToPoint() method.

What's the best way to parse them? Because I don't to re-implement something that already implemented.

1. POINT (106.864669442177 47.8991748467088)

2. LINESTRING (105.559202361852 47.9573920816183, 105.559594083577 47.9575918540359, 105.560169398785 47.9578764885664, 105.561418429017 47.9585039317608)

3. POLYGON ((634558.425 5308335.9859 1277.97, 634555.2962 5308367.5332 1277.97, 634544.5106 5308366.3938 1277.97, 634547.6093 5308334.9463 1277.97, 634558.425 5308335.9859 1277.97))

I'm doing something like this for now.

SpatialReference SP_WGS_84 = SpatialReference.create(4326);

Point point = CoordinateConversion.decimalDegreesToPoint("47.8991748467088 106.864669442177", SP_WGS_84)

0 Kudos
1 Solution

Accepted Solutions
EricBader
Occasional Contributor III

There are some good examples in this sample: Add graphics | ArcGIS for Developers 

Create Points, using geographic coordinates for example, as follows:

// points

Point point1 = new Point(13, 55.59);

Point point2 = new Point(72.83, 18.97);

Point point3 = new Point(5.43, 34.3);

The way to create a Polyline is as follows...

Polyline polyline = new Polyline();

polyline.startPath(118.169, 34.016);

polyline.lineTo(104.941, 39.7072);

polyline.lineTo(96.724, 32.732);

...and a Polygon:

Polygon polygon = new Polygon();

polygon.startPath(25, 5.59);

polygon.lineTo(13.42, 3.92);

polygon.lineTo(12.3, 23.3);

polygon.lineTo(38.2, 22.9);

polygon.closePathWithLine();

View solution in original post

1 Reply
EricBader
Occasional Contributor III

There are some good examples in this sample: Add graphics | ArcGIS for Developers 

Create Points, using geographic coordinates for example, as follows:

// points

Point point1 = new Point(13, 55.59);

Point point2 = new Point(72.83, 18.97);

Point point3 = new Point(5.43, 34.3);

The way to create a Polyline is as follows...

Polyline polyline = new Polyline();

polyline.startPath(118.169, 34.016);

polyline.lineTo(104.941, 39.7072);

polyline.lineTo(96.724, 32.732);

...and a Polygon:

Polygon polygon = new Polygon();

polygon.startPath(25, 5.59);

polygon.lineTo(13.42, 3.92);

polygon.lineTo(12.3, 23.3);

polygon.lineTo(38.2, 22.9);

polygon.closePathWithLine();