Skip to content

Latest commit

 

History

History
39 lines (32 loc) · 1.04 KB

README.md

File metadata and controls

39 lines (32 loc) · 1.04 KB

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 );