# Geometries

`Point`, `Multipoint`, `Polyline`, `Polygon`,和 `Envelope`都继承自`Geometry`

### Envelope(范围)

``````Envelope envelope = new Envelope(-123.0, 33.5, -101.0, 48.0, SpatialReferences.getWgs84());
``````

``````Envelope envelopePoints = new Envelope(pointOne, pointTwo);
``````

### Point（点）

• 了解点的坐标系
• 您可以使用`CoordinateFormatter`将纬度，经度格式的字符串直接转换为`Point`，还可以从现有`Point`返回纬度，经度格式的字符串。

### 多点（MultiPoint）

• MultiPoint 为只读集合，创建示例：
``````PointCollection stateCapitalsPST = new PointCollection(SpatialReferences.getWgs84());
stateCapitalsPST.add(-119.766999, 39.164885); // Carson City, NV
Multipoint multipoint = new Multipoint(stateCapitalsPST);
``````

``````for (Point pt : multipoint.getPoints()) {
Log.i(TAG, String.format("Point x=%f,y=%f, z=%f",  pt.getX(), pt.getY(), pt.getZ()));
}
``````

### 折线（Polyline）

``````PointCollection borderCAtoNV = new PointCollection(SpatialReferences.getWgs84());
Polyline polyline = new Polyline(borderCAtoNV);
``````

### 多边形（Polygon）

``````PointCollection coloradoCorners = new PointCollection(SpatialReferences.getWgs84());
``````

### Multipart (Polygon and Polyline)

``````// 第一种
// iterate each Part of a Polyline
ImmutablePartCollection parts = polyline.getParts();
for  (ImmutablePart part : parts)
{
// iterate the collection of Points representing vertices of the ImmutablePart
for (Point pt : part.getPoints())
{
Log.i(TAG, String.format("Point: x=%f,y=%f, z=%f", pt.getX(), pt.getY(), pt.getZ()));
}
// iterate each Segment - ImmutablePart is a collection of segments
for (Segment seg : part) {
Log.i(TAG, String.format("Segment: (%f, %f) to (%f %f)",
seg.getStartPoint().getX(), seg.getStartPoint().getY(),
seg.getEndPoint().getX(), seg.getEndPoint().getY()));
}
}
// 第二种
// get the combined set of Points from every ImmutablePart of a Polyline
for  (Point pt : polyline.getParts().getPartsAsPoints())
{
Log.i(TAG, String.format("Point: x=%f,y=%f, z=%f",
pt.getX(), pt.getY(), pt.getZ()));
}
``````

### Converting to and from JSON

``````// convert a Polygon to a JSON representation
String polygonJson = polygon.toJson();
// create a new Polygon from JSON
Polygon polygonFromJson = (Polygon) Polygon.fromJson(polygonJson);
``````