Hello,
I'm trying to save a shapefile from a MemoryDataStore.
The shapefile seems to be ok, however it is not saving the .prj file
properly, when I open it, it is empty (0 bytes).
When I call the createSchema(), I'm getting the following warning: "PRJ file
not generated for null CoordinateReferenceSystem". Then I tried some
debugging and I have found out that this piece of code found in class
ShapeFileDataStore.java is throwing an exception:
*if* (cs != *null*) {
*try* {
transformedBounds = env.transform(cs, *true*); <<-
exception happens here
} *catch* (Exception e) {
cs = null;
transformedBounds = env;
}
Please, help.
This is the message of the exception that is being caught in the
ShapeFileDataStore.java:
org.geotools.referencing.operation.projection.ProjectionException: The
transform result may be 111.319,871 meters away from the expected position.
Are you sure that the input coordinates are inside this map projection area
of validity? The point is located 0°00.0'E away from the central meridian
and 90°00.0'S away from the latitude of origin. The projection is
"Transverse_Mercator"
This is a println of the CRS of my GeometryDescriptor:
PROJCS["SAD_1969_UTM_Zone_23S",
GEOGCS["GCS_South_American_1969",
DATUM["D_South_American_1969",
SPHEROID["GRS_1967_Truncated", 6378160.0, 298.25]],
PRIMEM["Greenwich", 0.0],
UNIT["degree", 0.017453292519943295],
AXIS["Longitude", EAST],
AXIS["Latitude", NORTH]],
PROJECTION["Transverse_Mercator"],
PARAMETER["central_meridian", -45.0],
PARAMETER["latitude_of_origin", 0.0],
PARAMETER["scale_factor", 0.9996],
PARAMETER["false_easting", 500000.0],
PARAMETER["false_northing", 10000000.0],
UNIT["m", 1.0],
AXIS["x", EAST],
AXIS["y", NORTH]]
This is the code:
FeatureSource<SimpleFeatureType, SimpleFeature> memoryFeatureSource =
getFeatureSource();
SimpleFeatureType featureType = memoryFeatureSource.getSchema();
File file = *new* File(getFileName());
Map map = Collections.*singletonMap*("url",
file.toURI().toURL());
FileDataStoreFactorySpi factory = *new*ShapefileDataStoreFactory();
ShapefileDataStore shapeFileDataStore = (ShapefileDataStore)
factory
.createNewDataStore(map);
shapeFileDataStore.createSchema(featureType);
FeatureStore shapeFileFeatureStore = (FeatureStore) shapeFileDataStore
.getFeatureSource(featureType.getName());
Transaction t = new DefaultTransaction();
try {
Map features =
memory.getFeatures(featureType.getTypeName());
FeatureCollection collection =
FeatureCollections.newCollection();
collection.addAll(features.values());
shapeFileFeatureStore.addFeatures(collection);
t.commit(); // write it out
} catch (IOException eek) {
eek.printStackTrace();
try {
t.rollback();
} catch (IOException doubleEeek) {
// rollback failed?
}
} finally {
t.close();
}
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users