use of org.opengis.referencing.FactoryException in project sldeditor by robward-scisys.
the class CoordManager method processCRSEntry.
/**
* Process CRS entry.
*/
private void processCRSEntry() {
VendorOptionVersion vendorOptionVersion = VendorOptionManager.getInstance().getDefaultVendorOptionVersion();
ValueComboBoxData notSetValue = new ValueComboBoxData(NOT_SET_CRS, Localisation.getString(CoordManager.class, Localisation.COMMON_NOT_SET), vendorOptionVersion);
crsDataList.add(notSetValue);
Hints hints = null;
for (AuthorityFactory factory : ReferencingFactoryFinder.getCRSAuthorityFactories(hints)) {
String authorityCode = NOT_SET_CRS;
Citation citation = factory.getAuthority();
if (citation != null) {
@SuppressWarnings("unchecked") Collection<Identifier> identifierList = (Collection<Identifier>) citation.getIdentifiers();
authorityCode = identifierList.iterator().next().getCode();
}
Set<String> codeList;
try {
codeList = factory.getAuthorityCodes(CoordinateReferenceSystem.class);
for (String code : codeList) {
String fullCode = String.format("%s:%s", authorityCode, code);
String descriptionText = factory.getDescriptionText(code).toString();
String text = String.format("%s - %s", fullCode, descriptionText);
ValueComboBoxData value = new ValueComboBoxData(fullCode, text, vendorOptionVersion);
crsDataList.add(value);
crsMap.put(fullCode, value);
}
} catch (NoSuchAuthorityCodeException e) {
// Do nothing
} catch (FactoryException e) {
ConsoleManager.getInstance().exception(this, e);
}
}
}
use of org.opengis.referencing.FactoryException in project sldeditor by robward-scisys.
the class MapRender method convertToWGS84.
/**
* Convert referenced envelope to WGS 84.
*
* @param bounds the bounds
* @return the referenced envelope
*/
private ReferencedEnvelope convertToWGS84(ReferencedEnvelope bounds) {
if (bounds == null) {
return null;
}
CoordinateReferenceSystem wgs84 = CoordManager.getInstance().getWGS84();
if (wgs84.equals(bounds.getCoordinateReferenceSystem())) {
return bounds;
}
if (bounds.getCoordinateReferenceSystem() == null) {
return bounds;
}
MathTransform transform = null;
try {
transform = CRS.findMathTransform(bounds.getCoordinateReferenceSystem(), wgs84, true);
} catch (FactoryException e) {
ConsoleManager.getInstance().exception(this, e);
}
Envelope targetGeometry = null;
try {
targetGeometry = JTS.transform(bounds, transform);
} catch (TransformException e) {
ConsoleManager.getInstance().exception(this, e);
}
if (targetGeometry != null) {
return new ReferencedEnvelope(targetGeometry.getMinY(), targetGeometry.getMaxY(), targetGeometry.getMinX(), targetGeometry.getMaxX(), wgs84);
}
return null;
}
Aggregations