bouviervj / topojson-j

Topojson library for Java, based on topojson specifications.

Home Page:http://bouviervj.github.io/topojson-j/web/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

topojson-j

Topojson library for Java, based on topojson specifications. The base project reads .shp files, can convert them in Geojson files or Topojson files. Added a functionality to compress generated files with LZ4 lib.

Example

// Reading a shp file and writing it as compressed topojson
TopojsonApi.shpToTopojsonFile("./data/MA.shp", 
										  "./web/topojson.json", 
										  "MA", 
										  1000, 
										  4, 
										  true);

Base algorithm

// Extracting a FeatureCollection from shp file
FeatureCollection aCollection = shpToGeojsonFeatureCollection(iFileName);
		
// Then process the algorithm to create Topojson data
List<Entity> aEntities = aCollection.extract();
Entity.join(aEntities);
		
ArcMap aMap = new ArcMap();
for (Entity aEntity:aEntities){
	aEntity.cut(aMap);
}

Topology aTopology = new Topology();
aTopology.addObject( "MA" , aCollection.toTopology());
aTopology.setArcs(aMap);

aTopology.simplify( 1000 );
aTopology.quantize( 4 );

About

Topojson library for Java, based on topojson specifications.

http://bouviervj.github.io/topojson-j/web/

License:Apache License 2.0


Languages

Language:Java 96.9%Language:HTML 3.1%