1
Map<String,Object> params = ...; // postgis params
DataStore dataStore = DataStoreFinder.getDataStore(params);
SimpleFeatureCollection collection=...;// collection to save
SimpleFeatureType schema = collection.getSchema();
dataStore.createSchema(schema); // but it creates with name "polygon"
MyUtils.save(collection,dataStore);  // saves to database

schema before save: collection.getSchema().getCoordinateReferenceSystem().getCoordinateSystem().toString() :

EllipsoidalCS["GCS_WGS_1984",
 AXIS["longitude", EAST],
 AXIS["latitude", NORTH]]

postgresql table column definition:

fid          serial NOT NULL
the_geom     geometry(Point,4326)
Name         character varying(93)

But when I read a collection from the same source, I face:
schema after read: collection.getSchema().getCoordinateReferenceSystem().getCoordinateSystem().toString():

EllipsoidalCS["Ellipsoidal 2D CS. Axes: latitude, longitude. Orientation: north, east. UoM: degree",
 AXIS["Geodetic latitude", NORTH],
 AXIS["Geodetic longitude", EAST],
 AUTHORITY["EPSG","6422"]]

The problem is that the x y coordinates are displaced in the schema but the point values are not.
I gues geotools cannot decode "EPSG:4326" correctly. CRS.decode(string,boolean longitudeFirst) guides to solution and a related question answered here, but we can't change the collection.getSchema().
Problem of that question was creating a CRS with corrent axis order, but my problem is reading a feature collection with correct CRS.

8
  • Schema are immutable
    – Ian Turton
    Aug 2 '15 at 18:12
  • iant that question is so different. Do not mark duplicate!
    – Dariush
    Aug 3 '15 at 9:36
  • iant! I havn't got the solution. schema are immutable and I can't set CRS
    – Dariush
    Aug 3 '15 at 9:51
  • You can edit the question to clarify why it is not a duplicate.
    – Ian Turton
    Aug 3 '15 at 11:13
  • done! Problem of that question was creating a CRS with corrent axis order, but my problem is reading a feature collection with correct CRS.
    – Dariush
    Aug 3 '15 at 11:29