use of net.geoprism.registry.io.LatLonException in project geoprism-registry by terraframe.
the class ExcelImporter method getGeometry.
@Override
public Geometry getGeometry(FeatureRow row) {
if (this.config.isExternalImport() && this.config.getExternalSystem() instanceof RevealExternalSystem) {
return ((RevealExcelContentHandler) this.excelHandler).getGeometry();
} else {
ShapefileFunction latitudeFunction = this.config.getFunction(GeoObjectImportConfiguration.LATITUDE);
ShapefileFunction longitudeFunction = this.config.getFunction(GeoObjectImportConfiguration.LONGITUDE);
if (latitudeFunction != null && longitudeFunction != null) {
Object latitude = latitudeFunction.getValue(row);
Object longitude = longitudeFunction.getValue(row);
if (latitude != null && longitude != null) {
Double lat = new Double(latitude.toString());
Double lon = new Double(longitude.toString());
if (Math.abs(lat) > 90 || Math.abs(lon) > 180) {
LatLonException ex = new LatLonException();
ex.setLat(lat.toString());
ex.setLon(lon.toString());
throw ex;
}
ImportConfiguration configuration = this.objectImporter.getConfiguration();
if (configuration instanceof GeoObjectImportConfiguration) {
ServerGeoObjectType type = ((GeoObjectImportConfiguration) configuration).getType();
if (type.getGeometryType().equals(GeometryType.POINT) || type.getGeometryType().equals(GeometryType.MIXED)) {
return new Point(new CoordinateSequence2D(lon, lat), factory);
}
}
return new MultiPoint(new Point[] { new Point(new CoordinateSequence2D(lon, lat), factory) }, factory);
}
}
return null;
}
}
Aggregations