| | |
| | | import com.se.simu.domain.dto.GeField; |
| | | import com.se.simu.domain.dto.GeLayer; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.gdal.gdal.Band; |
| | | import org.gdal.gdal.Dataset; |
| | | import org.gdal.gdal.gdal; |
| | | import org.gdal.gdalconst.gdalconst; |
| | |
| | | import java.util.Map; |
| | | import java.util.Vector; |
| | | |
| | | /** |
| | | * ShapeFile帮助类 |
| | | * |
| | | * @author WWW |
| | | * @date 2024-09-13 |
| | | */ |
| | | @Slf4j |
| | | @SuppressWarnings("ALL") |
| | | public class ShpHelper { |
| | |
| | | } |
| | | } |
| | | |
| | | private static Geometry createPolygon(SpatialReference sr, Double minx, Double miny, Double maxx, Double maxy) { |
| | | public static Geometry createPolygon(SpatialReference sr, Double minx, Double miny, Double maxx, Double maxy) { |
| | | String epsg = sr.GetAuthorityCode(null); |
| | | if (!("4326".equals(epsg) || "4490".equals(epsg))) { |
| | | double[] dmin = GdalHelper.fromWgs84(sr, minx, miny); |
| | |
| | | |
| | | Geometry poly = new Geometry(ogr.wkbPolygon); |
| | | poly.AddGeometry(ring); |
| | | poly.AssignSpatialReference(sr); |
| | | |
| | | return poly; |
| | | } |
| | |
| | | f.SetField(i, local.getYear(), local.getMonthValue(), local.getDayOfMonth(), local.getHour(), local.getMinute(), local.getSecond(), 8); |
| | | } |
| | | |
| | | /** |
| | | * 创建Geometry对象 |
| | | */ |
| | | private static Geometry createGeometry(GeLayer geLayer, JSONObject geom) { |
| | | public static Geometry createGeometry(GeLayer geLayer, JSONObject geom) { |
| | | String type = geom.getStr("type"); |
| | | JSONArray cs = geom.getJSONArray("coordinates"); |
| | | |
| | |
| | | dataSource = driver.CreateDataSource(filePath, null); |
| | | if (null == dataSource) return false; |
| | | |
| | | layer = dataSource.CreateLayer(FileUtil.getName(filePath), ds.GetSpatialRef(), ogr.wkbPolygon, getOptions()); |
| | | layer = dataSource.CreateLayer(FileUtil.getName(filePath), ds.GetSpatialRef(), ogr.wkbPolygon); |
| | | if (null == layer) return false; |
| | | |
| | | layer.CreateField(new FieldDefn("val", ogr.OFTReal)); |