Geometry service GetLabelPoints method

The GetLablePoints method calculates points for label placement inside each input polygon.

GetLabelPoints(SpatialReference SpatialReference, Polygon[] InPolygonArray)

Parameter

Description

SpatialReference

The SpatialReference of the geometries in InPolygonArray. Cannot be null.

InPolygonArray

The array of Polygons on which to determine an optimum, interior label point. All geometries are assumed to be in the coordinate system defined by SpatialReference.

Return Value

An array of points(Point[]). You can cast each point to PointN.

Remarks

Generates one point geometry per input polygon. Each point is guaranteed to be inside its corresponding polygon.

Examples

C#

Geometry_GeometryServer geometryService = new Geometry_GeometryServer();

geometryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";

 

// GCS-NAD83

SpatialReference inputSpatialReference = geometryService.FindSRByWKID("EPSG", 4269, -1, true, true);

 

PointN pnt1 = new PointN();

pnt1.X = 10.0;

pnt1.Y = 30.0;

PointN pnt2 = new PointN();

pnt2.X = 10.0;

pnt2.Y = 40.0;

PointN pnt3 = new PointN();

pnt3.X = 20.0;

pnt3.Y = 40.0;

PointN pnt4 = new PointN();

pnt4.X = 20.0;

pnt4.Y = 30.0;

PointN pnt5 = new PointN();

pnt5.X = 10.0;

pnt5.Y = 30.0;

 

PointN[] pnts1 = new PointN[] { pnt1, pnt2, pnt3, pnt4, pnt5 };

Ring ring1 = new Ring();

ring1.PointArray = pnts1;

Ring[] rings = new Ring[] { ring1 };

 

PolygonN polygonn = new PolygonN();

polygonn.RingArray = rings;

PolygonN[] polygonArray = new PolygonN[] { polygonn };

 

Point[] labelPoints = (Point[])geometryService.GetLabelPoints(inputSpatialReference, polygonArray);

VB.NET

Dim geomeTryService As Geometry_GeometryServer = New Geometry_GeometryServer()

geomeTryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer"

 

' GCS-NAD83

Dim inputSpatialReference as SpatialReference = geomeTryService.FindSRByWKID("EPSG", 4269,-1, True, True)

 

Dim pnt1 As PointN = New PointN()

pnt1.X = 10.0

pnt1.Y = 30.0

 

Dim pnt2 As PointN = New PointN()

pnt2.X = 10.0

pnt2.Y = 40.0

 

Dim pnt3 As PointN = New PointN()

pnt3.X = 20.0

pnt3.Y = 40.0

 

Dim pnt4 As PointN = New PointN()

pnt4.X = 20.0

pnt4.Y = 30.0

 

Dim pnt5 As PointN = New PointN()

pnt5.X = 10.0

pnt5.Y = 30.0

 

Dim pnts1() As PointN = New PointN() {pnt1, pnt2, pnt3, pnt4, pnt5}

Dim ring1 As Ring = New Ring()

ring1.PointArray = pnts1

Dim rings() As Ring = New Ring() {ring1}

 

Dim polygonn As PolygonN = New PolygonN()

polygonn.RingArray = rings

Dim polygonArray() As PolygonN = New PolygonN() {polygonn}

 

Dim labelPoints As Point() = CType(geomeTryService.GetLabelPoints(inputSpatialReference, polygonArray), Point())

Java

String serviceURL = "http://localhost:6080/arcgis/services/Geometry/GeometryServer";

GeometryServerBindingStub geometryService = new GeometryServerBindingStub(serviceURL);


//Test GetLabelPoints

SpatialReference inputSpatialReference2 = geometryService.findSRByWKID(

      "EPSG", 4269, -1, true, true);

 

//Setup the geometry

PointN p1 = new PointN();

p1.setX(10.0);

p1.setY(30.0);

 

PointN p2 = new PointN();

p2.setX(10.0);

p2.setY(40.0);

 

PointN p3 = new PointN();

p3.setX(20.0);
p3.setY(40.0);

 

PointN p4 = new PointN();

p4.setX(20.0);

p4.setY(30.0);

 

PointN p5 = new PointN();

p5.setX(10.0);

p5.setY(30.0);

 

PointN[] points2 = new PointN[] { p1, p2, p3, p4, p5 };

 

Ring ring2 = new Ring();

ring2.setPointArray(points2);

 

Ring[] rings2 = new Ring[] { ring2 };

 

PolygonN polygonN2 = new PolygonN();

polygonN2.setRingArray(rings2);

    

PolygonN[] polygonArray2 = new PolygonN[] { polygonN2 };

 

//GetLabelPoints

Point[] labelPoints = (Point[]) geometryService.getLabelPoints(

      inputSpatialReference2, polygonArray2);

 

for (Point labelPoint : labelPoints)

{

      PointN labelPointN =  (PointN) labelPoint;

      System.out.println("Label Point: " + labelPointN.getX() + ", " + labelPointN.getY());

}

11/8/2016