本文整理汇总了Java中org.geotools.referencing.ReferencingFactoryFinder类的典型用法代码示例。如果您正苦于以下问题:Java ReferencingFactoryFinder类的具体用法?Java ReferencingFactoryFinder怎么用?Java ReferencingFactoryFinder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReferencingFactoryFinder类属于org.geotools.referencing包,在下文中一共展示了ReferencingFactoryFinder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFeatureType
import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
/**
* Create the schema for your FeatureType cq shapefile
*/
private static SimpleFeatureType createFeatureType() {
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setName("GeometryError");
try {
CRSAuthorityFactory authorityFactory = ReferencingFactoryFinder.getCRSAuthorityFactory("epsg", null);
builder.setCRS(authorityFactory.createCoordinateReferenceSystem("28992")); // <- Coordinate reference system
} catch(Exception e) {
throw new RuntimeException(e);
}
// add attributes
builder.add("Location", Point.class);
builder.add("InspireId", String.class);
builder.add("Message", String.class);
return builder.buildFeatureType();
}
示例2: getSRS
import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
private SRS getSRS() throws KettleException {
if (ogrLayer != null) {
if(ogrLayer.GetSpatialRef() != null) {
try {
CRSFactory crsFactory = ReferencingFactoryFinder.getCRSFactory(null);
CoordinateReferenceSystem crs = crsFactory.createFromWKT(ogrLayer.GetSpatialRef().ExportToWkt());
return new SRS(crs);
}
catch (FactoryException fe) {
// TODO Do we have to do anything else here, i.e. when a FactoryException occurs while parsing the CRS WKT of the data source?
return null;
}
}
else {
// TODO Do we have to do anything else here, i.e. when OGR SRS is set to unknown?
return null;
}
}
else {
throw new KettleException("OGR data source is not open");
}
}
示例3: getCRS
import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
@Override
public CoordinateReferenceSystem getCRS(final GeoPos referencePos, ParameterValueGroup parameters,
GeodeticDatum datum) throws FactoryException {
final CRSFactory crsFactory = ReferencingFactoryFinder.getCRSFactory(null);
// in some cases, depending on the parameters set, the effective transformation can be different
// from the transformation given by the OperationMethod.
// So we create a new one
final MathTransformFactory mtFactory = ReferencingFactoryFinder.getMathTransformFactory(null);
final MathTransform transform = mtFactory.createParameterizedTransform(parameters);
final DefaultOperationMethod operationMethod = new DefaultOperationMethod(transform);
final Conversion conversion = new DefiningConversion(AbstractIdentifiedObject.getProperties(operationMethod),
operationMethod, transform);
final HashMap<String, Object> baseCrsProperties = new HashMap<String, Object>();
baseCrsProperties.put("name", datum.getName().getCode());
GeographicCRS baseCrs = crsFactory.createGeographicCRS(baseCrsProperties,
datum,
DefaultEllipsoidalCS.GEODETIC_2D);
final HashMap<String, Object> projProperties = new HashMap<String, Object>();
projProperties.put("name", conversion.getName().getCode() + " / " + datum.getName().getCode());
return crsFactory.createProjectedCRS(projProperties, baseCrs, conversion, DefaultCartesianCS.PROJECTED);
}
示例4: createCrs
import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
CoordinateReferenceSystem createCrs(String crsName, OperationMethod method,
ParameterValueGroup parameters,
GeodeticDatum datum) throws FactoryException {
final CRSFactory crsFactory = ReferencingFactoryFinder.getCRSFactory(null);
final CoordinateOperationFactory coFactory = ReferencingFactoryFinder.getCoordinateOperationFactory(null);
final HashMap<String, Object> projProperties = new HashMap<String, Object>();
projProperties.put("name", crsName + " / " + datum.getName().getCode());
final Conversion conversion = coFactory.createDefiningConversion(projProperties,
method,
parameters);
final HashMap<String, Object> baseCrsProperties = new HashMap<String, Object>();
baseCrsProperties.put("name", datum.getName().getCode());
final GeographicCRS baseCrs = crsFactory.createGeographicCRS(baseCrsProperties, datum,
DefaultEllipsoidalCS.GEODETIC_2D);
return crsFactory.createProjectedCRS(projProperties, baseCrs, conversion, DefaultCartesianCS.PROJECTED);
}
示例5: createDatumSet
import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
public static Set<GeodeticDatum> createDatumSet() {
DatumAuthorityFactory factory = ReferencingFactoryFinder.getDatumAuthorityFactory("EPSG", null);
List<String> datumCodes = retrieveCodes(GeodeticDatum.class, factory);
Set<GeodeticDatum> datumSet = new TreeSet<>(AbstractIdentifiedObject.NAME_COMPARATOR);
for (String datumCode : datumCodes) {
try {
DefaultGeodeticDatum geodeticDatum = (DefaultGeodeticDatum) factory.createGeodeticDatum(datumCode);
if (geodeticDatum.getBursaWolfParameters().length != 0 ||
DefaultGeodeticDatum.isWGS84(geodeticDatum)) {
datumSet.add(geodeticDatum);
}
} catch (FactoryException ignored) {
}
}
return datumSet;
}
示例6: convertUTM_MGA942Geographic_EPSG4326
import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
public static Geometry convertUTM_MGA942Geographic_EPSG4326(Double easting, Double northing, String zone) throws NoSuchAuthorityCodeException, FactoryException, MismatchedDimensionException, TransformException{
CoordinateReferenceSystem geographic = CRS.decode("EPSG:4326", false);
CoordinateReferenceSystem geographic2 = ReferencingFactoryFinder.getCRSAuthorityFactory(
"EPSG", null).createCoordinateReferenceSystem("4326");
CoordinateReferenceSystem utm = ReferencingFactoryFinder.getCRSAuthorityFactory(
"EPSG", null).createCoordinateReferenceSystem("283"+zone);
CoordinateOperationFactory coFactory = ReferencingFactoryFinder
.getCoordinateOperationFactory(null);
CoordinateReferenceSystem sourceCRS = utm;
CoordinateReferenceSystem targetCRS = geographic;
GeometryFactory gf = new GeometryFactory();
Coordinate coord = new Coordinate( easting, northing );
Point point = gf.createPoint( coord );
MathTransform mathTransform =CRS.findMathTransform( sourceCRS, targetCRS,true );
Geometry g2 = JTS.transform(point, mathTransform);
//VT: Flip around to correct the lat lon from the utm to geographic transformation
Coordinate[] original = g2.getCoordinates();
for(int i = 0; i < original.length; i++){
Double swapValue = original[i].x;
original[i].x = original[i].y;
original[i].y = swapValue;
}
return g2;
}
示例7: filterCRSNames
import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
/**
* filters all CRS Names from all available CRS authorities
*
* @param filter
* array of keywords
* @return Set of CRS Names which contain all the filter keywords
*/
protected Set<String> filterCRSNames(final String[] filter) {
crsCodeMap = new HashMap<String, String>();
final Set<String> descriptions = new TreeSet<String>();
for (final Object object : ReferencingFactoryFinder.getCRSAuthorityFactories(null)) {
final CRSAuthorityFactory factory = (CRSAuthorityFactory) object;
try {
final Set<String> codes = factory.getAuthorityCodes(CoordinateReferenceSystem.class);
for (final Object codeObj : codes) {
final String code = (String) codeObj;
String description;
try {
description = factory.getDescriptionText(code).toString();
} catch (final Exception e1) {
description = "UNNAMED";
}
description += " (" + code + ")"; //$NON-NLS-1$ //$NON-NLS-2$
crsCodeMap.put(code, description);
if (matchesFilter(description.toUpperCase(), filter)) {
descriptions.add(description);
}
}
} catch (final FactoryException e) {
ExceptionMonitor.show(wktText.getShell(), e, "CRS Authority:" + e.getMessage());
}
}
return descriptions;
}
示例8: getAllSRSCodes
import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
/**
* @return A plain array with all EPSG-codes.
*/
public static String[] getAllSRSCodes() {
CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory(SRS.AUTH_EPSG, null);
try {
Set<String> srids = factory.getAuthorityCodes(CoordinateReferenceSystem.class);
String[] epsg_codes = new String[srids.size()];
return srids.toArray(epsg_codes);
} catch (FactoryException e) {
return null;
}
}
示例9: createComboSelectionSRS
import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
/**
* Creates the SRS from the selected SRID
*
* @param srid The srid from the selected Entry in Combo
*/
private void createComboSelectionSRS(String srid) {
String authority_epsg = Citations.getIdentifier(Citations.EPSG);
CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory(authority_epsg, null);
try {
if(srid == ""){
selectedSRS = SRS.UNKNOWN;
}else{
selectedSRS = new SRS(authority_epsg, srid, factory.getDescriptionText(srid).toString());
}
} catch (Exception ex) {
selectedSRS = new SRS("GeoKettle", srid, "Custom");
}
}
示例10: createCRS
import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
public CoordinateReferenceSystem createCRS(String crsWkt){
CoordinateReferenceSystem crs;
try {
crs = ReferencingFactoryFinder.getCRSFactory(null).createFromWKT(crsWkt);
return crs;
}catch (FactoryException exception) {
exception.printStackTrace();
return null;
}
}
示例11: getProperties
import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
/**
* Fills a {@link SRSInit} object with the correct initialization values
* needed by constructors (authority, description, srid).
*
* Note: The method tries to retrieve as much information from the
* {@link CoordinateReferenceSystem} <code>crs</code> as possible.
*
* @param init Pass the {@link SRSInit} object to allow multiple return-values.
* @param crs The {@link CoordinateReferenceSystem} where the information
* are retrieved from.
*/
private void getProperties(SRSInit init, CoordinateReferenceSystem crs) {
// Try to find srid, authority and description from the CRS.
// Abort if the correct EPSG identifiers were found.
Set<ReferenceIdentifier> identifiers = crs.getIdentifiers();
if (!identifiers.isEmpty()) {
for (ReferenceIdentifier id : identifiers) {
init.auth = Citations.getIdentifier(id.getAuthority());
init.srid = id.getCode();
try {
CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory(init.auth, HINTS);
init.desc = factory.getDescriptionText(init.srid).toString();
this.is_custom = false;
break;
} catch (Exception e) {
this.is_custom = true;
}
}
} else
this.is_custom = true;
// If this is not an EPSG spatial reference system, use WKT to describe it but get
// as much information as possible about the SRS from the WKT.
if (this.is_custom) {
init.srid = Const.NVL(init.srid, Integer.toString(UNKNOWN_SRID));
init.auth = Const.NVL(init.auth, "Custom Authority");
init.desc = Const.NVL(init.desc, "Custom SRS from WKT");
}
}
示例12: createCrsProviderSet
import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
public static Set<AbstractCrsProvider> createCrsProviderSet() {
MathTransformFactory factory = ReferencingFactoryFinder.getMathTransformFactory(null);
Set<OperationMethod> methods = factory.getAvailableMethods(Projection.class);
TreeSet<AbstractCrsProvider> crsProviderSet = new TreeSet<>(new CrsProviderComparator());
for (OperationMethod method : methods) {
crsProviderSet.add(new OperationMethodCrsProvider(method));
}
return crsProviderSet;
}
示例13: GridTransforms
import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
public GridTransforms(String espgCode) {
Spatial.initSpatial();
try {
crsFac = ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG", null);
wgs84crs = crsFac.createCoordinateReferenceSystem("4326");
gridcrs = crsFac.createCoordinateReferenceSystem(espgCode);
latLongToGrid = new DefaultCoordinateOperationFactory().createOperation(wgs84crs, gridcrs);
gridToLongLat = new DefaultCoordinateOperationFactory().createOperation(gridcrs, wgs84crs);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例14: initSpatial
import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
public static synchronized void initSpatial(){
if(!init){
// ensure geotools uses longitude, latitude order, not latitude, longitude, in the entire application
System.setProperty("org.geotools.referencing.forceXY", "true");
crsFac = ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG", null);
try {
wgs84crs = crsFac.createCoordinateReferenceSystem("4326");
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
}
示例15: transfGeom
import org.geotools.referencing.ReferencingFactoryFinder; //导入依赖的package包/类
/**
* Returns a geometry based on the transformation from a source geometry CRS
* to a defined target CRS.
*
*/
private Geometry transfGeom(Geometry g, CoordinateReferenceSystem outputCRS) throws TransformException, NoSuchAuthorityCodeException, FactoryException {
Hints hints = new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE);
CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG", hints);
CoordinateReferenceSystem srcCRS = factory.createCoordinateReferenceSystem("EPSG:4326");
outputCRS = factory.createCoordinateReferenceSystem("EPSG:900913");
MathTransform transform;
transform = CRS.findMathTransform(srcCRS, outputCRS, false);
Geometry trgGeom = JTS.transform(g, transform);
return trgGeom;
}