Skip to content

wetransform-os/topojson-j

 
 

Repository files navigation

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.

Resources

License

Stars

Watchers

Forks

Languages

  • Java 97.0%
  • HTML 3.0%