/* 设置空间参考 */
SpatialReference referenceA = SpatialReference.create(4326);
SpatialReference reference = SpatialReference.create(3857);
/* 待转换图形 */
Polygon geo
/* 步骤一: 将谷歌墨卡托平面坐标系上的图形转换为CGJ-02地理坐标系图形 */
geo = GeometryEngine.project(b_SHAPEs.get(i).getSHAPE(), reference, referenceA);
/* 步骤二:拆分CGJ-02地理坐标系图形 */
MultiPath multiPath = (MultiPath)geo;
List<Point> points = new ArrayList<Point>();
for (int j = 0; j < multiPath.getPointCount(); j++) {
// 注意这里将会把CGJ-02的点转化为WGS84的点 - 转化方式可以查找我的博客中: WGS84 | CGJ-02坐标系互转
double[] xy = CGJ02ToWGS84.Backstepping(multiPath
.getPoint(j).getX(), multiPath.getPoint(j)
.getY());
points.add(new Point(xy[0], xy[1]));
}
/* 重组 */
Polygon polygon = new Polygon();
for (int k = 0; k < points.size(); k++) {
if (k == 0) {
polygon.startPath(points.get(k));
} else {
polygon.lineTo(points.get(k));
}
}
/* 赋值 结束 */
geo = polygon;