use of com.vividsolutions.jts.io.ParseException in project UVMS-ActivityModule-APP by UnionVMS.
the class MapperUtil method getFaReportDocumentEntity.
public static FaReportDocumentEntity getFaReportDocumentEntity() {
FaReportDocumentEntity faReportDocumentEntity = new FaReportDocumentEntity();
faReportDocumentEntity.setStatus(FaReportStatusEnum.UPDATED.getStatus());
faReportDocumentEntity.setTypeCode("FISHING_OPERATION");
faReportDocumentEntity.setTypeCodeListId("FLUX_FA_REPORT_TYPE");
faReportDocumentEntity.setAcceptedDatetime(new Date());
faReportDocumentEntity.setFmcMarker("FMC Marker");
faReportDocumentEntity.setFmcMarkerListId("FMC Marker list Id");
Geometry geometry = null;
try {
geometry = wktReader.read("MULTIPOINT ((-10 40), (-40 30), (-20 20), (-30 10))");
} catch (ParseException e) {
e.printStackTrace();
}
faReportDocumentEntity.setGeom(geometry);
FaReportIdentifierEntity faReportIdentifierEntity = new FaReportIdentifierEntity();
faReportIdentifierEntity.setFaReportIdentifierId("Identifier Id 1");
faReportIdentifierEntity.setFaReportIdentifierSchemeId("57th785-tjf845-tjfui5-tjfuir8");
faReportIdentifierEntity.setFaReportDocument(faReportDocumentEntity);
faReportDocumentEntity.setFaReportIdentifiers(new HashSet<FaReportIdentifierEntity>(Arrays.asList(faReportIdentifierEntity)));
FluxReportDocumentEntity fluxReportDocumentEntity = getFluxReportDocumentEntity();
fluxReportDocumentEntity.setFaReportDocument(faReportDocumentEntity);
faReportDocumentEntity.setFluxReportDocument(fluxReportDocumentEntity);
return faReportDocumentEntity;
}
use of com.vividsolutions.jts.io.ParseException in project UVMS-ActivityModule-APP by UnionVMS.
the class SearchQueryBuilder method applyValueDependingOnKey.
private void applyValueDependingOnKey(Map<SearchFilter, String> searchCriteriaMap, Query typedQuery, SearchFilter key, String value) throws ServiceException {
switch(key) {
case PERIOD_START:
typedQuery.setParameter(queryParameterMappings.get(key), DateUtils.parseToUTCDate(value, DateUtils.DATE_TIME_UI_FORMAT));
break;
case PERIOD_END:
typedQuery.setParameter(queryParameterMappings.get(key), DateUtils.parseToUTCDate(value, DateUtils.DATE_TIME_UI_FORMAT));
break;
case QUANTITY_MIN:
typedQuery.setParameter(queryParameterMappings.get(key), SearchQueryBuilder.normalizeWeightValue(value, searchCriteriaMap.get(SearchFilter.WEIGHT_MEASURE)));
break;
case QUANTITY_MAX:
typedQuery.setParameter(queryParameterMappings.get(key), SearchQueryBuilder.normalizeWeightValue(value, searchCriteriaMap.get(SearchFilter.WEIGHT_MEASURE)));
break;
case MASTER:
typedQuery.setParameter(queryParameterMappings.get(key), value.toUpperCase());
break;
case FA_REPORT_ID:
typedQuery.setParameter(queryParameterMappings.get(key), Integer.parseInt(value));
break;
case AREA_GEOM:
Geometry geom;
try {
geom = GeometryMapper.INSTANCE.wktToGeometry(value).getValue();
geom.setSRID(GeometryUtils.DEFAULT_EPSG_SRID);
} catch (ParseException e) {
throw new ServiceException(e.getMessage(), e);
}
typedQuery.setParameter(queryParameterMappings.get(key), geom);
break;
default:
typedQuery.setParameter(queryParameterMappings.get(key), value);
break;
}
}
use of com.vividsolutions.jts.io.ParseException in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method getRestrictedAreaGeom.
private Geometry getRestrictedAreaGeom(List<Dataset> datasets) throws ServiceException {
if (CollectionUtils.isEmpty(datasets)) {
return null;
}
try {
List<AreaIdentifierType> areaIdentifierTypes = UsmUtils.convertDataSetToAreaId(datasets);
String areaWkt = spatialModule.getFilteredAreaGeom(areaIdentifierTypes);
Geometry geometry = GeometryMapper.INSTANCE.wktToGeometry(areaWkt).getValue();
geometry.setSRID(GeometryUtils.DEFAULT_EPSG_SRID);
return geometry;
} catch (ParseException e) {
throw new ServiceException(e.getMessage(), e);
}
}
use of com.vividsolutions.jts.io.ParseException in project UVMS-ActivityModule-APP by UnionVMS.
the class FluxMessageServiceBean method getGeometryFromSpatial.
/**
* Get Geometry information from spatial for FLUXLocation code
* @param fluxLocationIdentifier
* @return
*/
private Geometry getGeometryFromSpatial(String fluxLocationIdentifier) {
log.info("Get Geometry from Spatial for:" + fluxLocationIdentifier);
if (fluxLocationIdentifier == null) {
return null;
}
Geometry geometry = null;
try {
String geometryWkt = spatialModuleService.getGeometryForPortCode(fluxLocationIdentifier);
if (geometryWkt != null) {
Geometry value = GeometryMapper.INSTANCE.wktToGeometry(geometryWkt).getValue();
Coordinate[] coordinates = value.getCoordinates();
if (coordinates.length > 0) {
Coordinate coordinate = coordinates[0];
double x = coordinate.x;
double y = coordinate.y;
geometry = GeometryUtils.createPoint(x, y);
}
}
log.debug(" Geometry received from Spatial for:" + fluxLocationIdentifier + " :" + geometryWkt);
} catch (ServiceException | ParseException e) {
log.error("Exception while trying to get geometry from spatial", e);
}
return geometry;
}
use of com.vividsolutions.jts.io.ParseException in project incubator-rya by apache.
the class GeoMesaGeoIndexer method deleteStatements.
private void deleteStatements(final Collection<RyaStatement> ryaStatements) throws IOException {
// create a feature collection
final DefaultFeatureCollection featureCollection = new DefaultFeatureCollection();
for (final RyaStatement ryaStatement : ryaStatements) {
final Statement statement = RyaToRdfConversions.convertStatement(ryaStatement);
// if the predicate list is empty, accept all predicates.
// Otherwise, make sure the predicate is on the "valid" list
final boolean isValidPredicate = validPredicates.isEmpty() || validPredicates.contains(statement.getPredicate());
if (isValidPredicate && (statement.getObject() instanceof Literal)) {
try {
final SimpleFeature feature = createFeature(featureType, statement);
featureCollection.add(feature);
} catch (final ParseException e) {
logger.warn("Error getting geo from statement: " + statement.toString(), e);
}
}
}
// remove this feature collection from the store
if (!featureCollection.isEmpty()) {
final Set<Identifier> featureIds = new HashSet<Identifier>();
final FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(null);
final Set<String> stringIds = DataUtilities.fidSet(featureCollection);
for (final String id : stringIds) {
featureIds.add(filterFactory.featureId(id));
}
final Filter filter = filterFactory.id(featureIds);
featureStore.removeFeatures(filter);
}
}
Aggregations