本文整理了Java中org.geotools.referencing.CRS.parseWKT()
方法的一些代码示例,展示了CRS.parseWKT()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CRS.parseWKT()
方法的具体详情如下:
包路径:org.geotools.referencing.CRS
类名称:CRS
方法名:parseWKT
[英]Parses a Well Known Text (WKT) into a CRS object. This convenience method is a shorthand for the following: FactoryFinder. ReferencingFactoryFinder#getCRSFactory(null). org.opengis.referencing.crs.CRSFactory#createFromWKT(wkt);
[中]将{$0$}(WKT)解析为CRS对象。此方便方法是以下内容的简写:FactoryFinder. ReferencingFactoryFinder#getCRSFactory(null). org.opengis.referencing.crs.CRSFactory#createFromWKT(wkt);
代码示例来源:origin: geoserver/geoserver
@Override
public Object fromString(String str) {
if (str.toUpperCase().startsWith("EPSG:")) {
try {
return CRS.decode(str);
} catch (Exception e) {
XStreamPersister.LOGGER.log(Level.WARNING, "Error decode epsg code: " + str, e);
}
} else {
try {
return CRS.parseWKT(str);
} catch (FactoryException e) {
XStreamPersister.LOGGER.log(Level.WARNING, "Error decode wkt: " + str, e);
}
}
return null;
}
}
代码示例来源:origin: geoserver/geoserver
@Override
public Object fromString(String str) {
try {
return CRS.parseWKT(str);
} catch (Exception e) {
try {
return new SRSConverter().fromString(str);
} catch (Exception e1) {
}
throw new RuntimeException(e);
}
}
}
代码示例来源:origin: geoserver/geoserver
if ((paramValues.get(index) != null)
&& (((String) paramValues.get(index)).length() > 0)) {
value = CRS.parseWKT((String) paramValues.get(index));
代码示例来源:origin: geoserver/geoserver
if (key.equalsIgnoreCase("crs")) {
if ((params.get(key) != null) && (((String) params.get(key)).length() > 0)) {
value = CRS.parseWKT((String) params.get(key));
} else {
LOGGER.info("Unable to find a crs for the coverage param, using EPSG:4326");
代码示例来源:origin: geoserver/geoserver
@Test
public void testSRSConverter() throws Exception {
CoordinateReferenceSystem crs = CRS.decode("EPSG:4901");
SRSConverter c = new SRSConverter();
assertEquals("EPSG:4901", c.toString(crs));
// definition with odd UOM that won't be matched to the EPSG one
assertFalse(
"EPSG:4901"
.equals(
c.toString(
CRS.parseWKT(
"GEOGCS[\"GCS_ATF_Paris\",DATUM[\"D_ATF\",SPHEROID[\"Plessis_1817\",6376523.0,308.64]],PRIMEM[\"Paris\",2.337229166666667],UNIT[\"Grad\",0.01570796326794897]]"))));
}
代码示例来源:origin: geoserver/geoserver
CoordinateReferenceSystem crs = CRS.parseWKT(nativeCrsWkt);
coverage.setNativeCRS(crs);
代码示例来源:origin: geoserver/geoserver
@Test
public void testInitCoverageSRSLookup_GEOS8973() throws Exception {
Catalog cat = getCatalog();
CatalogBuilder cb = new CatalogBuilder(cat);
cb.setStore(cat.getCoverageStoreByName(MockData.WORLD.getLocalPart()));
CoverageInfo cinfo = cb.buildCoverage();
cinfo.setSRS(null);
String wkt =
"GEOGCS[\"ED50\",\n"
+ " DATUM[\"European Datum 1950\",\n"
+ " SPHEROID[\"International 1924\", 6378388.0, 297.0]],\n"
+ "PRIMEM[\"Greenwich\", 0.0],\n"
+ "UNIT[\"degree\", 0.017453292519943295]]";
CoordinateReferenceSystem testCRS = CRS.parseWKT(wkt);
cinfo.setNativeCRS(testCRS);
cb.initCoverage(cinfo, "srs lookup");
assertEquals("EPSG:4230", cinfo.getSRS());
}
代码示例来源:origin: geotools/geotools
private CoordinateReferenceSystem getLambertPolar() throws FactoryException {
String crsWKT =
"PROJCS[\"North_Pole_Lambert_Azimuthal_Equal_Area\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\","
+ "SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],"
+ "PROJECTION[\"Lambert_Azimuthal_Equal_Area\"],PARAMETER[\"False_Easting\",0],PARAMETER[\"False_Northing\",0],"
+ "PARAMETER[\"Central_Meridian\",0],PARAMETER[\"Latitude_Of_Origin\",90],UNIT[\"Meter\",1]]";
return CRS.parseWKT(crsWKT);
}
代码示例来源:origin: geotools/geotools
/** Returns a ED50 CRS with the specified name. */
private static CoordinateReferenceSystem getED50(final String name) throws FactoryException {
final String wkt =
"GEOGCS[\""
+ name
+ "\",\n"
+ " DATUM[\"European Datum 1950\",\n"
+ " SPHEROID[\"International 1924\", 6378388.0, 297.0]],\n"
+ "PRIMEM[\"Greenwich\", 0.0],\n"
+ "UNIT[\"degree\", 0.017453292519943295]]";
return CRS.parseWKT(wkt);
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testReprojectLayerGroup()
throws NoSuchAuthorityCodeException, FactoryException, Exception {
Catalog catalog = getCatalog();
CatalogBuilder cb = new CatalogBuilder(catalog);
LayerGroupInfo lg = catalog.getFactory().createLayerGroup();
LayerInfo l = catalog.getLayerByName(getLayerId(MockData.ROAD_SEGMENTS));
lg.getLayers().add(l);
lg.getStyles().add(null);
lg.setName("test-reproject");
// EPSG:4901 "equivalent" but different uom
String wkt =
"GEOGCS[\"GCS_ATF_Paris\",DATUM[\"D_ATF\",SPHEROID[\"Plessis_1817\",6376523.0,308.64]],PRIMEM[\"Paris\",2.337229166666667],UNIT[\"Grad\",0.01570796326794897]]";
CoordinateReferenceSystem lCrs = CRS.parseWKT(wkt);
((FeatureTypeInfo) l.getResource()).setSRS(null);
((FeatureTypeInfo) l.getResource()).setNativeCRS(lCrs);
assertNull(CRS.lookupEpsgCode(lCrs, false));
// Use the real thing now
CoordinateReferenceSystem lgCrs = CRS.decode("EPSG:4901");
assertNotNull(CRS.lookupEpsgCode(lgCrs, false));
// Reproject our layer group to EPSG:4901. We expect it to have an EPSG code.
cb.calculateLayerGroupBounds(lg, lgCrs);
assertNotNull(CRS.lookupEpsgCode(lg.getBounds().getCoordinateReferenceSystem(), false));
}
代码示例来源:origin: geotools/geotools
static Geometry reprojectAndDensify(
Geometry first,
CoordinateReferenceSystem sourceCRS,
CoordinateReferenceSystem targetCRS)
throws FactoryException, TransformException {
if (targetCRS == null) {
targetCRS = CRS.parseWKT(ECKERT_IV_WKT);
}
MathTransform firstTransform = CRS.findMathTransform(sourceCRS, targetCRS);
Geometry geometry = JTS.transform(densify(first, sourceCRS, 0.01d), firstTransform);
return geometry;
}
代码示例来源:origin: geotools/geotools
/** Tests the {@link CRS#parseWKT} method. */
public void testWKT() throws FactoryException {
String wkt =
"GEOGCS[\"WGS 84\",\n"
+ " DATUM[\"WGS_1984\",\n"
+ " SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],\n"
+ " TOWGS84[0,0,0,0,0,0,0], AUTHORITY[\"EPSG\",\"6326\"]],\n"
+ " PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],\n"
+ " UNIT[\"DMSH\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],\n"
+ " AXIS[\"Lat\",NORTH], AXIS[\"Long\",EAST],\n"
+ " AUTHORITY[\"EPSG\",\"4326\"]]";
CoordinateReferenceSystem crs = CRS.parseWKT(wkt);
assertNotNull(crs);
}
代码示例来源:origin: geotools/geotools
@Test
public void parseWKT() throws Exception {
String[] wkts = {
"PROJCS[\"Wagner_IV\", GEOGCS[\"WGS84\", DATUM[\"WGS84\", SPHEROID[\"WGS84\", 6378137.0, 298.257223563]], PRIMEM[\"Greenwich\", 0.0], UNIT[\"degree\",0.017453292519943295], AXIS[\"Longitude\",EAST], AXIS[\"Latitude\",NORTH]], PROJECTION[\"Wagner_IV\"], UNIT[\"m\", 1.0], AXIS[\"Easting\", EAST], AXIS[\"Northing\", NORTH]]",
"PROJCS[\"Wagner_V\", GEOGCS[\"WGS84\", DATUM[\"WGS84\", SPHEROID[\"WGS84\", 6378137.0, 298.257223563]], PRIMEM[\"Greenwich\", 0.0], UNIT[\"degree\",0.017453292519943295], AXIS[\"Longitude\",EAST], AXIS[\"Latitude\",NORTH]], PROJECTION[\"Wagner_V\"], UNIT[\"m\", 1.0], AXIS[\"Easting\", EAST], AXIS[\"Northing\", NORTH]]"
};
for (String wkt : wkts) {
assertNotNull(CRS.parseWKT(wkt));
}
}
代码示例来源:origin: geotools/geotools
@Test
public void testLambertParsing() throws FactoryException {
String initialLambertWkt =
"PROJCS[\"LAMBERT WKT\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\","
+ "SPHEROID[\"WGS_1984\",6371200.0,0]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\","
+ "0.017453292519943295]],PROJECTION[\"Lambert_Conformal_Conic\"],"
+ "PARAMETER[\"standard_parallel_1\",25.0],PARAMETER[\"latitude_of_origin\",25.0],"
+ "PARAMETER[\"central_meridian\",-95.0],PARAMETER[\"false_easting\",0],"
+ "PARAMETER[\"false_northing\",0],PARAMETER[\"Scale_Factor\",1.0],UNIT[\"m\",1]]";
CoordinateReferenceSystem lambertCRS = CRS.parseWKT(initialLambertWkt);
String parsedLambertWkt = lambertCRS.toWKT();
CoordinateReferenceSystem lambertCRS2 = CRS.parseWKT(parsedLambertWkt);
assertTrue(CRS.equalsIgnoreMetadata(lambertCRS, lambertCRS2));
}
代码示例来源:origin: geotools/geotools
/**
* GEOT-1702, make sure looking up for a non existing code does not result in a {@link
* StackOverflowException}.
*
* @throws FactoryException If the CRS can't be created.
*/
@Test
public void testLookupFailing() throws FactoryException {
CoordinateReferenceSystem crs = CRS.parseWKT(WKT.MERCATOR_GOOGLE);
assertNull(CRS.lookupIdentifier(crs, true));
}
代码示例来源:origin: geotools/geotools
public void testLenient() throws Exception {
CoordinateReferenceSystem lenientTarget;
lenientTarget =
CRS.parseWKT(
"PROJCS[\"MGI (Ferro) / Austria GK West Zone\",GEOGCS[\"MGI (Ferro)\",DATUM[\"Militar_Geographische_Institut_Ferro\",SPHEROID[\"Bessel 1841\",6377397.155,299.1528128,AUTHORITY[\"EPSG\",\"7004\"]],AUTHORITY[\"EPSG\",\"6805\"]],PRIMEM[\"Ferro\",-17.66666666666667,AUTHORITY[\"EPSG\",\"8909\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4805\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",28],PARAMETER[\"scale_factor\",1],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",-5000000],AUTHORITY[\"EPSG\",\"31251\"],AXIS[\"Y\",EAST],AXIS[\"X\",NORTH]]");
SimpleFeatureIterator reproject =
new ReprojectingFeatureCollection(delegate, lenientTarget).features();
reproject.close();
}
代码示例来源:origin: geotools/geotools
@BeforeClass
public static void setupClass() throws FactoryException, TransformException {
sphericalGeosCRS = CRS.parseWKT(sphericalGeosWKT);
sphericalGeosToGeog =
CRS.findMathTransform(
sphericalGeosCRS, CRS.getProjectedCRS(sphericalGeosCRS).getBaseCRS(), true);
geogToSphericalGeos = sphericalGeosToGeog.inverse();
ellipsoidalGeosCRS = CRS.parseWKT(ellipsoidalGeosWKT);
ellipsoidalGeosToGeog =
CRS.findMathTransform(
ellipsoidalGeosCRS,
CRS.getProjectedCRS(ellipsoidalGeosCRS).getBaseCRS(),
true);
geogToEllipsoidalGeos = ellipsoidalGeosToGeog.inverse();
}
代码示例来源:origin: geotools/geotools
protected void setUp() throws Exception {
super.setUp();
target =
CRS.parseWKT(
"PROJCS[\"BC_Albers\",GEOGCS[\"GCS_North_American_1983\",DATUM[\"North_American_Datum_1983\",SPHEROID[\"GRS_1980\",6378137,298.257222101],TOWGS84[0,0,0]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Albers_Conic_Equal_Area\"],PARAMETER[\"False_Easting\",1000000],PARAMETER[\"False_Northing\",0],PARAMETER[\"Central_Meridian\",-126],PARAMETER[\"Standard_Parallel_1\",50],PARAMETER[\"Standard_Parallel_2\",58.5],PARAMETER[\"Latitude_Of_Origin\",45],UNIT[\"Meter\",1],AUTHORITY[\"EPSG\",\"42102\"]]");
MathTransform2D tx =
(MathTransform2D)
ReferencingFactoryFinder.getCoordinateOperationFactory(null)
.createOperation(crs, target)
.getMathTransform();
transformer = new GeometryCoordinateSequenceTransformer();
transformer.setMathTransform(tx);
transformer.setCoordinateReferenceSystem(target);
}
代码示例来源:origin: geotools/geotools
@Test
public void testTransformExtraMZ() throws Exception {
LiteCoordinateSequence cs = new LiteCoordinateSequence(1, 4);
cs.setArray(new double[] {1000000, 4000000, 25, 48});
CoordinateReferenceSystem sourceCrs = CRS.parseWKT(JTSTest.UTM_ZONE_10N);
CoordinateReferenceSystem destCrs = DefaultGeographicCRS.WGS84;
DefaultCoordinateSequenceTransformer cst;
cst = new DefaultCoordinateSequenceTransformer(new LiteCoordinateSequenceFactory());
MathTransform tx = CRS.findMathTransform(sourceCrs, destCrs, true);
LiteCoordinateSequence transformed = (LiteCoordinateSequence) cst.transform(cs, tx);
assertEquals(25.0, transformed.getOrdinate(0, 2), 0.0);
assertEquals(48.0, transformed.getOrdinate(0, 3), 0.0);
}
代码示例来源:origin: geotools/geotools
@Test
public void testLiteToStandard() throws Exception {
LiteCoordinateSequence cs = new LiteCoordinateSequence(1, 2);
cs.setArray(new double[] {1000000, 4000000});
CoordinateReferenceSystem sourceCrs = CRS.parseWKT(JTSTest.UTM_ZONE_10N);
CoordinateReferenceSystem destCrs = DefaultGeographicCRS.WGS84;
DefaultCoordinateSequenceTransformer cst;
cst = new DefaultCoordinateSequenceTransformer(/* standard cs factory */ );
MathTransform tx = CRS.findMathTransform(sourceCrs, destCrs, true);
CoordinateSequence transformed = cst.transform(cs, tx);
CoordinateSequence reference = transform(cs, tx);
assertEquals(reference.getOrdinate(0, 0), transformed.getOrdinate(0, 0), 0.0);
assertEquals(reference.getOrdinate(0, 1), transformed.getOrdinate(0, 1), 0.0);
}
内容来源于网络,如有侵权,请联系作者删除!