Thank you for the information.

-
Sunish.


On Wed, Jun 25, 2014 at 4:34 AM, Jody Garnett <jody.garn...@gmail.com>
wrote:

> I thought geojson defined things as "geometry".
>
> Yep: http://geojson.org
>
> GeoJson is not alone in this, when representing a shapefile GeoTools
> always uses a fake attribute called "the_geom"
>
> In general when converting between formats a bit of work is needed to
> account for their differences.  Another example using shapefile is string
> length, the DBF file used for attributes has smaller string length limits
> than modern developers are used to.
>
>
> Jody Garnett
>
>
> On Tue, Jun 24, 2014 at 9:57 PM, sunish <sunish.ku...@gmail.com> wrote:
>
>> 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
>>
>>
>
------------------------------------------------------------------------------
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

Reply via email to