| | |
| | | /** |
| | | * WGS84转换为目标坐标 |
| | | */ |
| | | public static int fromWgs84(SpatialReference sr, Geometry point) { |
| | | public static int fromWgs84(SpatialReference sr, Geometry g) { |
| | | // https://blog.csdn.net/weixin_34910922/article/details/129208661 |
| | | CoordinateTransformation ct = new CoordinateTransformation(GdalHelper.SR4326, sr); |
| | | if (sr.IsProjected() != 1) { |
| | | sr.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER); |
| | | } |
| | | |
| | | return point.TransformTo(sr); |
| | | return g.TransformTo(sr); |
| | | } |
| | | |
| | | public static Geometry createPolygon(SpatialReference sr, Double minx, Double miny, Double maxx, Double maxy) { |
| | | Geometry ring = new Geometry(ogr.wkbLinearRing); |
| | | ring.AddPoint_2D(minx, maxy); |
| | | ring.AddPoint_2D(maxx, maxy); |
| | | ring.AddPoint_2D(maxx, miny); |
| | | ring.AddPoint_2D(minx, miny); |
| | | ring.AddPoint_2D(minx, maxy); |
| | | |
| | | Geometry poly = new Geometry(ogr.wkbPolygon); |
| | | poly.AddGeometry(ring); |
| | | if (null != sr) { |
| | | poly.AssignSpatialReference(sr); |
| | | } |
| | | |
| | | return poly; |
| | | } |
| | | } |