本文整理汇总了Java中org.opengis.referencing.crs.CRSAuthorityFactory类的典型用法代码示例。如果您正苦于以下问题:Java CRSAuthorityFactory类的具体用法?Java CRSAuthorityFactory怎么用?Java CRSAuthorityFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CRSAuthorityFactory类属于org.opengis.referencing.crs包,在下文中一共展示了CRSAuthorityFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toShapeFile
import org.opengis.referencing.crs.CRSAuthorityFactory; //导入依赖的package包/类
/**
* write a shapefile representing the grid in a coordinate ref system ex :
* "EPSG:2975" -> RGR92, "EPSG:2154" -> L93, "EPSG:4326" -> WGS84
*
* @param fileName
* @param epsg
*/
public void toShapeFile(String fileName, String epsg) {
FT_FeatureCollection<IFeature> pop = new FT_FeatureCollection<>();
System.out.println("writing..." + fileName);
for (int i = 0; i < nbRows(); ++i)
for (int j = 0; j < nbCols(); ++j)
pop.add(new DefaultFeature(tiles[i][j]));
CRSAuthorityFactory factory = CRS.getAuthorityFactory(true);
CoordinateReferenceSystem crs = null;
try {
crs = factory.createCoordinateReferenceSystem(epsg);
} catch (FactoryException e) {
e.printStackTrace();
}
ShapefileWriter.write(pop, fileName, crs);
System.out.println("writing done");
}
示例2: createFeatureType
import org.opengis.referencing.crs.CRSAuthorityFactory; //导入依赖的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();
}
示例3: selectCRS
import org.opengis.referencing.crs.CRSAuthorityFactory; //导入依赖的package包/类
/**
* search the CRS database and return any which include the string provided.
*
* @param value
* - a string to search for.
* @return an ArrayList of CRS that match (may be empty, but not null).
*/
private ArrayList<CoordinateReferenceSystem> selectCRS(String value) {
String lValue = value.toLowerCase();
ArrayList<CoordinateReferenceSystem> ret = new ArrayList<CoordinateReferenceSystem>();
ArrayList<CoordinateReferenceSystem> possibles = listCRS();
CRSAuthorityFactory factory = CRS.getAuthorityFactory(false);
for (CoordinateReferenceSystem crs : possibles) {
if (crs.getName().getCode().toLowerCase().contains(lValue)) {
ret.add(crs);
} else if (crs.getName().getCodeSpace() != null
&& crs.getName().getCodeSpace().toLowerCase().contains(lValue)) {
ret.add(crs);
} else if (crs.getRemarks() != null
&& crs.getRemarks().toString().contains(lValue)) {
ret.add(crs);
} else if (crs.getCoordinateSystem().getRemarks() != null
&& crs.getCoordinateSystem().getRemarks().toString().toLowerCase()
.contains(lValue)) {
ret.add(crs);
}
}
return ret;
}
示例4: listDb
import org.opengis.referencing.crs.CRSAuthorityFactory; //导入依赖的package包/类
/**
* ask the Authority Factory to provide a list of CRS codes and Descriptions.
*
* @return a list of strings, code\tdescription.
*/
private ArrayList<String> listDb() {
ArrayList<String> ret = new ArrayList<String>();
CRSAuthorityFactory authFac = CRS.getAuthorityFactory(false);
try {
Set<String> list = authFac
.getAuthorityCodes(CoordinateReferenceSystem.class);
for (String code : list) {
ret.add(code + "\t" + authFac.getDescriptionText(code));
}
} catch (FactoryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return ret;
}
示例5: shutdownResources
import org.opengis.referencing.crs.CRSAuthorityFactory; //导入依赖的package包/类
@Override
public void shutdownResources() {
List<CRSAuthorityFactory> candidates = new ArrayList<>(2);
candidates.add(org.geotools.referencing.CRS.getAuthorityFactory(true));
candidates.add(org.geotools.referencing.CRS.getAuthorityFactory(false));
candidates.stream().filter((factory) -> (factory != null)).map((factory) -> {
if (factory instanceof DeferredAuthorityFactory) {
DeferredAuthorityFactory.exit();
}
return factory;
}).filter((factory) -> (factory instanceof AbstractAuthorityFactory)).forEach((factory) -> {
try {
((AbstractAuthorityFactory) factory).dispose();
} catch (FactoryException fe) {
logger.error("Error while GeometryHandler clean up", fe);
}
});
}
示例6: filterCRSNames
import org.opengis.referencing.crs.CRSAuthorityFactory; //导入依赖的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;
}
示例7: testInvertQueryNorthEastAxisOrder
import org.opengis.referencing.crs.CRSAuthorityFactory; //导入依赖的package包/类
@Test
public void testInvertQueryNorthEastAxisOrder() throws Exception {
Filter filter = ff.bbox("geom", 0, 0, 0, 0, "EPSG:4326");
CRSAuthorityFactory factory = CRS.getAuthorityFactory(false);
CoordinateReferenceSystem crs = factory.createCoordinateReferenceSystem("EPSG:4326");
ReferencedEnvelope env = new ReferencedEnvelope(2,3,0,1,crs);
Query query = new Query();
query.setFilter(filter);
Query queryOut = process.invertQuery(env, query, null);
assertEquals(ff.bbox("geom", 0, 2, 1, 3, "EPSG:4326"), queryOut.getFilter());
}
示例8: getAllSRSCodes
import org.opengis.referencing.crs.CRSAuthorityFactory; //导入依赖的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.opengis.referencing.crs.CRSAuthorityFactory; //导入依赖的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: getProperties
import org.opengis.referencing.crs.CRSAuthorityFactory; //导入依赖的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");
}
}
示例11: retrieveCodes
import org.opengis.referencing.crs.CRSAuthorityFactory; //导入依赖的package包/类
private static void retrieveCodes(Set<String> codes, Class<? extends CoordinateReferenceSystem> crsType,
CRSAuthorityFactory factory) {
Set<String> localCodes;
try {
localCodes = factory.getAuthorityCodes(crsType);
} catch (FactoryException ignore) {
return;
}
codes.addAll(localCodes);
}
示例12: transfGeom
import org.opengis.referencing.crs.CRSAuthorityFactory; //导入依赖的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;
}
示例13: CrsInfo
import org.opengis.referencing.crs.CRSAuthorityFactory; //导入依赖的package包/类
CrsInfo(String crsCode, CRSAuthorityFactory factory) {
this.crsCode = crsCode;
this.factory = factory;
}
示例14: AutoCrsInfo
import org.opengis.referencing.crs.CRSAuthorityFactory; //导入依赖的package包/类
AutoCrsInfo(String epsgCode, CRSAuthorityFactory factory) {
super(epsgCode, factory);
}
示例15: getCrsFac
import org.opengis.referencing.crs.CRSAuthorityFactory; //导入依赖的package包/类
public CRSAuthorityFactory getCrsFac() {
return crsFac;
}