How can I convert shapefile to geojson using worldwind?
I have created “Shapefile”:
Shapefile shapefile = new Shapefile(shpInputStream, shxInputStream,dbfInputStream, prjInputStream);
log.debug("shapefile.getShapeType():"+shapefile.getShapeType());
And I can get the shapefile’s Bbox and featureNum:
bbox = shapefile.getBoundingRectangle();
log.debug("bbox[0]:"+bbox[0]);
log.debug("bbox[1]:"+bbox[1]);
log.debug("bbox[2]:"+bbox[2]);
log.debug("bbox[3]:"+bbox[3]);
int featureNum = shapefile.getNumberOfRecords();
log.debug("featureNum:"+featureNum);
But how can I convert it into geojson next step?
while (shapefile.hasNext())
{
ShapefileRecord record = shapefile.nextRecord();
log.debug("record.getShapeType():"+record.getShapeType());
log.debug("record.getAttributes():"+record.getAttributes());
log.debug("record.getAttributes().getValue("FCNAME"):"+record.getAttributes().getValue("FCNAME"));
log.debug("record.getAttributes().getValue("FENAME"):"+record.getAttributes().getValue("FENAME"));
log.debug("record.getAttributes().getValue("OBJECTID"):"+record.getAttributes().getValue("OBJECTID"));
log.debug("record.getAttributes().getValue("the_geom"):"+record.getAttributes().getValue("the_geom"));
//VecBuffer vb = record.getPointBuffer(0);
//log.debug("vb.getLocations():"+vb.getLocations());
//Polygon pgonAirspace = new Polygon(vb.getLocations());
//log.debug("pgonAirspace.getLocations():"+pgonAirspace.getLocations());
//break;
}