Hello,
I have a feature with geometry attribute named the_geom.
But when I write the feature to JSON the attribute name is getting changed
to 'geometry'.
So there is a mismatch when I convert it back to SimpleFeature.
Is there any way to preserve the geometry attribute name when creating
FeaturJSON.
I am testing with the following code snippet:
------------------------------------------------------
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
import java.io.IOException;
import java.io.StringWriter;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.geotools.data.DataUtilities;
import org.geotools.feature.SchemaException;
import org.geotools.feature.simple.SimpleFeatureBuilder;
import org.geotools.geojson.feature.FeatureJSON;
import org.geotools.geometry.jts.JTSFactoryFinder;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
/**
*
* @author sunish
*/
public class FutureJsonTest {
public static void main(String[] s){
try {
SimpleFeatureType featureType=DataUtilities.createType("TYPE",
"the_geom:Point,name:String,tag:String");
SimpleFeatureBuilder fb = new SimpleFeatureBuilder(featureType);
GeometryFactory gf = JTSFactoryFinder.getGeometryFactory();
fb.add(gf.createPoint(new Coordinate(12, 10)));
fb.add("P1");
fb.add("T2");
SimpleFeature f = fb.buildFeature(null);
System.out.println(f);
StringWriter writer = new StringWriter();
FeatureJSON fj = new FeatureJSON();
fj.writeFeature(f, writer);
System.out.println(writer.toString());
} catch (SchemaException | IOException ex) {
Logger.getLogger(FutureJsonTest.class.getName()).log(Level.SEVERE, null,
ex);
}
}
}
-------------------------------------
Thanks,
Sunish.
------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users