本文整理了Java中org.geotools.referencing.CRS.getSupportedCodes()
方法的一些代码示例,展示了CRS.getSupportedCodes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CRS.getSupportedCodes()
方法的具体详情如下:
包路径:org.geotools.referencing.CRS
类名称:CRS
方法名:getSupportedCodes
[英]Get the list of the codes that are supported by the given authority. For example getSupportedCodes("EPSG") may returns "EPSG:2000", "EPSG:2001", "EPSG:2002", etc. It may also returns "2000", "2001", "2002", etc. without the "EPSG:" prefix. Whatever the authority name is prefixed or not is factory implementation dependent.
If there is more than one factory for the given authority, then this method merges the code set of all of them. If a factory fails to provide a set of supported code, then this particular factory is ignored. Please be aware of the following potential issues:
#decode(c)
will use the same authority factory than the one that formatted c.If a more determinist behavior is wanted, consider the code below instead. The following code exploit only one factory, the "preferred" one.CRSAuthorityFactory factory = FactoryFinder. ReferencingFactoryFinder#getCRSAuthorityFactory(authority, null); Set<String> codes = factory. CRSAuthorityFactory#getAuthorityCodes(CoordinateReferenceSystem.class); String code = ...choose a code here... CoordinateReferenceSystem crs = factory.createCoordinateReferenceSystem(code);
[中]获取给定权限支持的代码列表。例如,getSupportedCodes(“EPSG”)可能返回“EPSG:2000”、“EPSG:2001”、“EPSG:2002”等。它也可能返回“2000”、“2001”、“2002”等,但不带“EPSG:”前缀。无论权限名称是否加前缀,都取决于工厂实现。
如果给定权限有多个工厂,则此方法合并所有工厂的代码集。如果工厂未能提供一组受支持的代码,则忽略此特定工厂。请注意以下潜在问题:
*如果有多个EPSG数据库(例如org.geotools.referenceing.factory.EPSG.AccessDataSource和org.geotools.referenceing.factory.EPSG.PostgreDataSource数据库),则此方法将连接到所有这些数据库,即使它们的内容相同。
*如果两个工厂的代码格式不同(例如“4326”和“EPSG:4326”),则返回的集合将包含大量同义代码。
*对于返回集中的任何代码c,不保证#decode(c)
将使用与格式化c相同的授权工厂。
*此方法不会报告连接问题,因为它不会引发任何异常。FactoryException记录为警告,否则将被忽略。
如果需要一个更具决定论的行为,请考虑下面的代码。以下代码仅利用一个工厂,即“首选”工厂。CRSAuthorityFactory factory = FactoryFinder. ReferencingFactoryFinder#getCRSAuthorityFactory(authority, null); Set<String> codes = factory. CRSAuthorityFactory#getAuthorityCodes(CoordinateReferenceSystem.class); String code = ...choose a code here... CoordinateReferenceSystem crs = factory.createCoordinateReferenceSystem(code);
代码示例来源:origin: geotools/geotools
@Test
public void testCodeInList() {
Set<String> supportedCodes = CRS.getSupportedCodes("EPSG");
assertTrue(supportedCodes.contains(CODE));
}
代码示例来源:origin: org.geoserver.web/web-core
static List<SRS> buildCodeList() {
long t = System.currentTimeMillis();
Set<String> codes = CRS.getSupportedCodes("EPSG");
try {
codes.addAll(customFactory.getAuthorityCodes(CoordinateReferenceSystem.class));
} catch (FactoryException e) {
LOGGER.log(Level.WARNING, "Error occurred while trying to gather custom CRS codes", e);
}
// make a set with each code
Set<SRS> idSet = new HashSet<SRS>();
for (String code : codes) {
// make sure we're using just the non prefix part
String id = code.substring(code.indexOf(':') + 1);
// avoid WGS84DD and eventual friends, as we're still not able to handle them,
// if they are chosen exceptions arises everywhere
if (NUMERIC.matcher(id).matches()) {
idSet.add(new SRS(id));
}
}
List<SRS> srsList = new ArrayList<SRS>(idSet);
Collections.sort(srsList, new CodeComparator()); // sort to get them in order
return srsList;
}
代码示例来源:origin: org.geoserver.web/gs-web-core
static List<SRS> buildCodeList() {
// long t = System.currentTimeMillis();
Set<String> codes = CRS.getSupportedCodes("EPSG");
try {
codes.addAll(customFactory.getAuthorityCodes(CoordinateReferenceSystem.class));
} catch (FactoryException e) {
LOGGER.log(Level.WARNING, "Error occurred while trying to gather custom CRS codes", e);
}
// make a set with each code
Set<SRS> idSet = new HashSet<SRS>();
for (String code : codes) {
// make sure we're using just the non prefix part
String id = code.substring(code.indexOf(':') + 1);
// avoid WGS84DD and eventual friends, as we're still not able to handle them,
// if they are chosen exceptions arises everywhere
if (NUMERIC.matcher(id).matches()) {
idSet.add(new SRS(id));
}
}
List<SRS> srsList = new ArrayList<SRS>(idSet);
Collections.sort(srsList, new CodeComparator()); // sort to get them in order
return srsList;
}
代码示例来源:origin: org.geoserver/gs-wms
comment("All supported EPSG projections:");
capabilitiesCrsIdentifiers = new LinkedHashSet<String>();
for (String code : CRS.getSupportedCodes("AUTO")) {
if ("WGS84(DD)".equals(code)) continue;
capabilitiesCrsIdentifiers.add("AUTO:" + code);
capabilitiesCrsIdentifiers.addAll(CRS.getSupportedCodes("EPSG"));
} else {
comment("Limited list of EPSG projections:");
代码示例来源:origin: org.geoserver/wms
if(epsgCodes.isEmpty()){
comment("All supported EPSG projections:");
capabilitiesCrsIdentifiers = CRS.getSupportedCodes("EPSG");
}else{
comment("Limited list of EPSG projections:");
代码示例来源:origin: org.geoserver/gs-wms
comment("All supported EPSG projections:");
capabilitiesCrsIdentifiers = new LinkedHashSet<String>();
for (String code : CRS.getSupportedCodes("AUTO")) {
if ("WGS84(DD)".equals(code)) continue;
capabilitiesCrsIdentifiers.add("AUTO:" + code);
capabilitiesCrsIdentifiers.addAll(CRS.getSupportedCodes("EPSG"));
} else {
comment("Limited list of EPSG projections:");
代码示例来源:origin: org.geoserver/gs-wms
@Test
public void testCRSList() throws Exception {
GetCapabilitiesTransformer tr;
tr = new GetCapabilitiesTransformer(wmsConfig, baseUrl, mapFormats, legendFormats, null);
tr.setIndentation(2);
Document dom = WMSTestSupport.transform(req, tr);
final Set<String> supportedCodes = CRS.getSupportedCodes("EPSG");
supportedCodes.addAll(CRS.getSupportedCodes("AUTO"));
NodeList allCrsCodes =
XPATH.getMatchingNodes("/WMT_MS_Capabilities/Capability/Layer/SRS", dom);
assertEquals(supportedCodes.size() - 1 /* WGS84(DD) */, allCrsCodes.getLength());
}
代码示例来源:origin: org.geoserver/gs-wcs2_0
codes = CRS.getSupportedCodes("EPSG");
} else {
codes = wcs.getSRS();
内容来源于网络,如有侵权,请联系作者删除!