| | |
| | | package com.se.nsl; |
| | | |
| | | import com.se.nsl.domain.po.Region; |
| | | import com.se.nsl.helper.GdalHelper; |
| | | import com.se.nsl.mapper.RegionMapper; |
| | | import javafx.scene.input.DataFormat; |
| | | import org.gdal.gdal.Dataset; |
| | | import org.gdal.gdal.Driver; |
| | | import org.gdal.gdal.gdal; |
| | | import org.gdal.gdalconst.gdalconst; |
| | | import org.gdal.gdalconst.gdalconstConstants; |
| | | import org.gdal.ogr.*; |
| | | import org.junit.Test; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.net.*; |
| | |
| | | |
| | | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) |
| | | public class AppTest { |
| | | @Resource |
| | | RegionMapper regionMapper; |
| | | |
| | | @Test |
| | | public void insertRegion() { |
| | | GdalHelper.init("D:\\soft\\release-1928-x64-dev\\release-1928-x64\\bin"); |
| | | String path = "D:\\Documents\\WeChat Files\\wxid_llap8o5q8rm521\\FileStorage\\File\\2025-04\\孙胡沟geometry.json"; |
| | | |
| | | org.gdal.ogr.Driver driver = ogr.GetDriverByName("GeoJSON"); |
| | | if (null == driver) return; |
| | | |
| | | DataSource ds = driver.Open(path); |
| | | if (null == ds) return; |
| | | |
| | | List<Region> list = new ArrayList<>(); |
| | | for (int i = 0, c = ds.GetLayerCount(); i < c; i++) { |
| | | Layer layer = ds.GetLayer(i); |
| | | for (long j = 0, d = layer.GetFeatureCount(); j < d; j++) { |
| | | Feature f = layer.GetFeature(j); |
| | | Geometry g = f.GetGeometryRef(); |
| | | if (null != g) { // && (g.GetGeometryType() == ogr.wkbPolygon || g.GetGeometryType() == ogr.wkbMultiPolygon) |
| | | list.add(new Region(f.GetFieldAsString(""), (short) 3, g.ExportToWkt())); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (list.size() > 0) { |
| | | regionMapper.inserts(list); |
| | | } |
| | | |
| | | ds.delete(); |
| | | driver.delete(); |
| | | |
| | | System.out.println("hello world"); |
| | | } |
| | | |
| | | //@Test |
| | | public void procDepthFiles() { |
| | | String path = "D:\\other\\simu\\uwsolver\\20250412\\depth"; |