本文整理汇总了Java中org.opengis.referencing.crs.CoordinateReferenceSystem.getIdentifiers方法的典型用法代码示例。如果您正苦于以下问题:Java CoordinateReferenceSystem.getIdentifiers方法的具体用法?Java CoordinateReferenceSystem.getIdentifiers怎么用?Java CoordinateReferenceSystem.getIdentifiers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opengis.referencing.crs.CoordinateReferenceSystem
的用法示例。
在下文中一共展示了CoordinateReferenceSystem.getIdentifiers方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCRSCode
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的package包/类
/**
* Gets the CRS code.
*
* @param coordinateReferenceSystem the coordinate reference system
* @return the CRS code
*/
public String getCRSCode(CoordinateReferenceSystem coordinateReferenceSystem) {
ReferenceIdentifier identifier = null;
if (coordinateReferenceSystem != null) {
Set<ReferenceIdentifier> indentifierList = coordinateReferenceSystem.getIdentifiers();
if (indentifierList != null) {
if (indentifierList.iterator().hasNext()) {
identifier = indentifierList.iterator().next();
}
}
}
String code = NOT_SET_CRS;
if (identifier != null) {
ValueComboBoxData data = crsMap.get(identifier.toString());
if (data != null) {
code = data.getKey();
}
}
return code;
}
示例2: haveCommonReferenceIdentifiers
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的package包/类
private static boolean haveCommonReferenceIdentifiers(CoordinateReferenceSystem crs1, CoordinateReferenceSystem crs2) {
Set<ReferenceIdentifier> identifiers1 = crs1.getIdentifiers();
Set<ReferenceIdentifier> identifiers2 = crs2.getIdentifiers();
// If a CRS does not have identifiers or if they have different number of identifiers
// they cannot be equal.
if (identifiers1 == null || identifiers1.isEmpty()
|| identifiers2 == null || identifiers2.isEmpty()
|| identifiers1.size() != identifiers2.size()) {
return false;
}
// The two CRSs can only be equal if they have the same number of identifiers
// and all of them are common to both.
int eqCount = 0;
for (ReferenceIdentifier refId1 : identifiers1) {
for (ReferenceIdentifier refId2 : identifiers2) {
if (compareRefIds(refId1, refId2)) {
eqCount++;
break;
}
}
}
return eqCount == identifiers1.size();
}
示例3: getCRSIdentifier
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的package包/类
private String getCRSIdentifier(CoordinateReferenceSystem coordinateReferenceSystem) {
String name = "";
if (coordinateReferenceSystem.getIdentifiers() == null) {
name = coordinateReferenceSystem.getName().toString();
} else {
for (ReferenceIdentifier identifier : coordinateReferenceSystem.getIdentifiers()) {
name = identifier.toString();
break;
}
}
return name;
}
示例4: getProperties
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的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");
}
}
示例5: gotoCRS
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的package包/类
/**
* Takes in a CRS, finds it in the list and highlights it
*
* @param crs
*/
@SuppressWarnings("unchecked")
public void gotoCRS(final CoordinateReferenceSystem crs) {
if (crs != null) {
final List list = codesList.getList();
final Set<Identifier> identifiers = new HashSet<Identifier>(crs.getIdentifiers());
final Set<Integer> candidates = new HashSet<Integer>();
for (int i = 0; i < list.getItemCount(); i++) {
for (final Identifier identifier : identifiers) {
final String item = list.getItem(i);
if (sameEPSG(crs, identifier, item) || exactMatch(crs, identifier, item)) {
codesList.setSelection(new StructuredSelection(item), false);
list.setTopIndex(i);
return;
}
if (isMatch(crs, identifier, item)) {
candidates.add(i);
}
}
}
if (candidates.isEmpty()) {
final java.util.List<String> input = (java.util.List<String>) codesList.getInput();
final String sourceCRSName = crs.getName().toString();
sourceCRS = crs;
input.add(0, sourceCRSName);
codesList.setInput(input);
codesList.setSelection(new StructuredSelection(sourceCRSName), false);
list.setTopIndex(0);
try {
final String toWKT = crs.toWKT();
wktText.setText(toWKT);
} catch (final RuntimeException e) {
ExceptionMonitor.show(wktText.getShell(), e, crs.toString() + " cannot be formatted as WKT"); //$NON-NLS-1$
wktText.setText("Unknown/Illegal WKT");
}
} else {
final Integer next = candidates.iterator().next();
codesList.setSelection(new StructuredSelection(list.getItem(next)), false);
list.setTopIndex(next);
}
}
}
示例6: getCRS
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的package包/类
/**
* returns the selected CRS
*
* @return selected CRS
*/
public CoordinateReferenceSystem getCRS() {
if (folder == null)
return selectedCRS;
if (folder.getSelectionIndex() == 1) {
try {
final String text = wktText.getText();
final CoordinateReferenceSystem createdCRS = ReferencingFactoryFinder.getCRSFactory(null)
.createFromWKT(text);
if (keywordsText.getText().trim().length() > 0) {
final Preferences node = findNode(createdCRS.getName().getCode());
if (node != null) {
final Preferences kn = node.node(ALIASES_ID);
final String[] keywords = keywordsText.getText().split(","); //$NON-NLS-1$
kn.clear();
for (String string : keywords) {
string = string.trim().toUpperCase();
if (string.length() > 0)
kn.put(string, string);
}
kn.flush();
} else {
CoordinateReferenceSystem found = createCRS(createdCRS.getName().getCode());
if (found != null && CRS.findMathTransform(found, createdCRS, true).isIdentity()) {
saveKeywords(found);
return found;
}
final Set<Identifier> identifiers = new HashSet<Identifier>(createdCRS.getIdentifiers());
for (final Identifier identifier : identifiers) {
found = createCRS(identifier.toString());
if (found != null && CRS.findMathTransform(found, createdCRS, true).isIdentity()) {
saveKeywords(found);
return found;
}
}
return saveCustomizedCRS(text, true, createdCRS);
}
}
return createdCRS;
} catch (final Exception e) {
ExceptionMonitor.show(wktText.getShell(), e);
}
}
if (selectedCRS == null) {
final String crsCode = (String) ((IStructuredSelection) codesList.getSelection()).getFirstElement();
if (sourceCRS != null && crsCode.equals(sourceCRS.getName().toString())) {
// System.out.println("source crs: " +
// sourceCRS.getName().toString());
return sourceCRS;
}
return createCRS(searchText.getText());
}
return selectedCRS;
}
示例7: saveCustomizedCRS
import org.opengis.referencing.crs.CoordinateReferenceSystem; //导入方法依赖的package包/类
/**
* @param text
* @param createdCRS
* @throws CoreException
* @throws IOException
* @throws BackingStoreException
*/
private CoordinateReferenceSystem saveCustomizedCRS(final String text, final boolean processWKT,
final CoordinateReferenceSystem createdCRS) throws CoreException, IOException, BackingStoreException {
final Preferences root = Preferences.userRoot();
final Preferences node = root.node(CUSTOM_ID);
int lastID;
String code;
String name;
String newWKT;
if (processWKT) {
lastID = Integer.parseInt(node.get(LAST_ID, "0")); //$NON-NLS-1$
code = "UDIG:" + lastID; //$NON-NLS-1$
name = createdCRS.getName().toString() + "(" + code + ")";//$NON-NLS-1$ //$NON-NLS-2$
lastID++;
node.putInt(LAST_ID, lastID);
newWKT = processingWKT(text, lastID);
} else {
final Set<ReferenceIdentifier> ids = createdCRS.getIdentifiers();
if (!ids.isEmpty()) {
final Identifier id = ids.iterator().next();
code = id.toString();
name = createdCRS.getName().getCode() + " (" + code + ")"; //$NON-NLS-1$ //$NON-NLS-2$
} else {
name = code = createdCRS.getName().getCode();
}
newWKT = text;
}
final Preferences child = node.node(code);
child.put(NAME_ID, name);
child.put(WKT_ID, newWKT);
final String[] keywords = keywordsText.getText().split(","); //$NON-NLS-1$
if (keywords.length > 0) {
final Preferences keyworkNode = child.node(ALIASES_ID);
for (String string : keywords) {
string = string.trim().toUpperCase();
keyworkNode.put(string, string);
}
}
node.flush();
return createdCRS;
}