整体更新
This commit is contained in:
parent
bf41e4b225
commit
83e2d1ad22
9
pom.xml
9
pom.xml
@ -229,6 +229,11 @@
|
|||||||
<artifactId>gt-swing</artifactId>
|
<artifactId>gt-swing</artifactId>
|
||||||
<version>${geotools.version}</version>
|
<version>${geotools.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>no.ecc.vectortile</groupId>
|
||||||
|
<artifactId>java-vector-tile</artifactId>
|
||||||
|
<version>1.2.1</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
@ -242,5 +247,9 @@
|
|||||||
<name>Open Source Geospatial Foundation Repository</name>
|
<name>Open Source Geospatial Foundation Repository</name>
|
||||||
<url>http://download.osgeo.org/webdav/geotools/</url>
|
<url>http://download.osgeo.org/webdav/geotools/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>ECC</id>
|
||||||
|
<url>https://github.com/ElectronicChartCentre/ecc-mvn-repo/raw/master/releases</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
package com.gis3c;
|
package com.gis3c;
|
||||||
|
|
||||||
import com.gis3c.entity.C3Map;
|
import com.gis3c.entity.C3Map;
|
||||||
import org.apache.commons.dbcp.datasources.SharedPoolDataSource;
|
import com.gis3c.entity.GeoCity;
|
||||||
import org.geotools.data.FeatureSource;
|
import com.gis3c.service.PostGISService;
|
||||||
|
import no.ecc.vectortile.VectorTileDecoder;
|
||||||
|
import no.ecc.vectortile.VectorTileEncoder;
|
||||||
|
import org.apache.commons.collections.map.HashedMap;
|
||||||
import org.geotools.data.FileDataStore;
|
import org.geotools.data.FileDataStore;
|
||||||
import org.geotools.data.FileDataStoreFinder;
|
import org.geotools.data.FileDataStoreFinder;
|
||||||
import org.geotools.data.shapefile.ShapefileDataStore;
|
import org.geotools.data.shapefile.ShapefileDataStore;
|
||||||
@ -14,17 +17,20 @@ import org.geotools.styling.SLD;
|
|||||||
import org.geotools.styling.SLDParser;
|
import org.geotools.styling.SLDParser;
|
||||||
import org.geotools.styling.Style;
|
import org.geotools.styling.Style;
|
||||||
import org.geotools.styling.StyleFactory;
|
import org.geotools.styling.StyleFactory;
|
||||||
import org.geotools.swing.JMapFrame;
|
|
||||||
import org.geotools.swing.data.JFileDataStoreChooser;
|
import org.geotools.swing.data.JFileDataStoreChooser;
|
||||||
import org.geotools.swing.dialog.JExceptionReporter;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.geotools.swing.styling.JSimpleStyleDialog;
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
import org.opengis.feature.simple.SimpleFeatureType;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
public static ApplicationContext ContextInit(){
|
||||||
|
return new ClassPathXmlApplicationContext("classpath:spring-config.xml");
|
||||||
|
}
|
||||||
public static StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory();
|
public static StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory();
|
||||||
// public static Style createStyle(File file, FeatureSource featureSource) {
|
// public static Style createStyle(File file, FeatureSource featureSource) {
|
||||||
// File sld = toSLDFile(file);
|
// File sld = toSLDFile(file);
|
||||||
@ -61,7 +67,7 @@ public class Main {
|
|||||||
// }
|
// }
|
||||||
// return null;
|
// return null;
|
||||||
// }
|
// }
|
||||||
public static void main(String[] args) throws IOException {
|
public static void StyleTest()throws IOException{
|
||||||
File file = JFileDataStoreChooser.showOpenFile("shp",null);
|
File file = JFileDataStoreChooser.showOpenFile("shp",null);
|
||||||
if(file == null){
|
if(file == null){
|
||||||
return;
|
return;
|
||||||
@ -83,7 +89,39 @@ public class Main {
|
|||||||
map.addLayer(layer);
|
map.addLayer(layer);
|
||||||
map.saveImage("D://mapimage//1.jpg",256);
|
map.saveImage("D://mapimage//1.jpg",256);
|
||||||
System.out.println("image has saved");
|
System.out.println("image has saved");
|
||||||
// JMapFrame.showMap(map);
|
}
|
||||||
|
public static void copy(Reader in,Writer out) throws IOException {
|
||||||
|
int c = -1;
|
||||||
|
while((c = in.read()) != -1) {
|
||||||
|
out.write(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void VectorTilesTest()throws IOException{
|
||||||
|
ApplicationContext context =ContextInit();
|
||||||
|
PostGISService postGISService = (PostGISService) context.getBean("postGISService");
|
||||||
|
List<GeoCity> geoCities = postGISService.AllCities();
|
||||||
|
|
||||||
|
VectorTileEncoder encoder = new VectorTileEncoder();
|
||||||
|
VectorTileDecoder d = new VectorTileDecoder();
|
||||||
|
byte[] encoded;
|
||||||
|
geoCities.forEach(city -> {
|
||||||
|
Map<String,String> cityAttr = new HashMap<>();
|
||||||
|
cityAttr.put("name",city.getName());
|
||||||
|
cityAttr.put("code",city.getCode());
|
||||||
|
encoder.addFeature("city",cityAttr,city.getGeom());
|
||||||
|
});
|
||||||
|
encoded = encoder.encode();
|
||||||
|
|
||||||
|
Reader in = new FileReader("C:\\Users\\Administrator\\Desktop\\0.vector.pbf");
|
||||||
|
StringWriter out = new StringWriter();
|
||||||
|
copy(in,out);
|
||||||
|
|
||||||
|
// System.out.println(out.toString());
|
||||||
|
System.out.println(d.decode(out.toString().getBytes()));
|
||||||
|
}
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
VectorTilesTest();
|
||||||
|
//VectorTilesTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -119,7 +119,7 @@
|
|||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<select id="allCity" resultMap="geoCity">
|
<select id="allCity" resultMap="geoCity">
|
||||||
select t."CODE" as code,t."NAME" as name, t.geom
|
select t.code as code,t.name as name, t.geom
|
||||||
from geocity t;
|
from geocity t;
|
||||||
--where t."CODE"='370300';
|
--where t."CODE"='370300';
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user