Hi,
I have the following the code
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
import java.io.File;
import java.io.IOException;
import org.geotools.data.FileDataStore;
import org.geotools.data.FileDataStoreFinder;
import org.geotools.data.simple.SimpleFeatureSource;
import org.geotools.referencing.CRS;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.NoSuchAuthorityCodeException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import fr.guyasim.core.Activator;
public class TestCrsEgality {
public static void main(String[] args) {
/** get Feature Collection */
FileDataStore store;
try {
String dir = "D:/mydirt/datatest/";
File shapeFile = new File(dir + "one-polygone.shp");
CoordinateReferenceSystem testCrs = CRS.decode("EPSG:32622");
store = FileDataStoreFinder.getDataStore(shapeFile);
SimpleFeatureSource featureSource = store.getFeatureSource();
if (featureSource == null) {
Activator.logInfo("store is null");
}
CoordinateReferenceSystem shapeFileCrs = featureSource.getBounds()
.getCoordinateReferenceSystem();
System.out.println("shapeFile CRS" + shapeFileCrs.toString());
System.out.println("shapeFile EPSG CODE "
+ CRS.lookupIdentifier(shapeFileCrs, true));
System.out
.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
System.out.println("testCrs CRS" + testCrs.toString());
System.out.println("testCrs EPSG CODE "
+ CRS.lookupIdentifier(testCrs, true));
System.out.println("shapeFile CRS is equal to testCrs :"
+ CRS.equalsIgnoreMetadata(shapeFileCrs, testCrs));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("Error");
} catch (NoSuchAuthorityCodeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FactoryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The result is
hapeFile CRSPROJCS["WGS_1984_UTM_Zone_22N",
GEOGCS["GCS_WGS_1984",
DATUM["D_WGS_1984",
SPHEROID["WGS_1984", 6378137.0, 298.257223563]],
PRIMEM["Greenwich", 0.0],
UNIT["degree", 0.017453292519943295],
AXIS["Longitude", EAST],
AXIS["Latitude", NORTH]],
PROJECTION["Transverse_Mercator"],
PARAMETER["central_meridian", -51.0],
PARAMETER["latitude_of_origin", 0.0],
PARAMETER["scale_factor", 0.9996],
PARAMETER["false_easting", 500000.0],
PARAMETER["false_northing", 0.0],
UNIT["m", 1.0],
AXIS["x", EAST],
AXIS["y", NORTH]]
shapeFile EPSG CODE EPSG:32622
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
testCrs CRSPROJCS["WGS 84 / UTM zone 22N",
GEOGCS["WGS 84",
DATUM["World Geodetic System 1984",
SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],
UNIT["degree", 0.017453292519943295],
AXIS["Geodetic latitude", NORTH],
AXIS["Geodetic longitude", EAST],
AUTHORITY["EPSG","4326"]],
PROJECTION["Transverse_Mercator", AUTHORITY["EPSG","9807"]],
PARAMETER["central_meridian", -51.0],
PARAMETER["latitude_of_origin", 0.0],
PARAMETER["scale_factor", 0.9996],
PARAMETER["false_easting", 500000.0],
PARAMETER["false_northing", 0.0],
UNIT["m", 1.0],
AXIS["Easting", EAST],
AXIS["Northing", NORTH],
AUTHORITY["EPSG","32622"]]
testCrs EPSG CODE EPSG:32622
shapeFile CRS is equal to testCrs :false
I do not understand why the two CRS have the same EPSG code but they are not
equal ?
Can anyone help me on this problem ?
Best regards
Thomas
------------------------------------------------------------------------------
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13.
http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users