Search in sources :

Example 6 with ParseException

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;
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) FluxReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity) ParseException(com.vividsolutions.jts.io.ParseException) FaReportIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportIdentifierEntity) Date(java.util.Date)

Example 7 with ParseException

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;
    }
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) ParseException(com.vividsolutions.jts.io.ParseException)

Example 8 with ParseException

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);
    }
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) ParseException(com.vividsolutions.jts.io.ParseException) AreaIdentifierType(eu.europa.ec.fisheries.uvms.spatial.model.schemas.AreaIdentifierType)

Example 9 with ParseException

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;
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) Coordinate(com.vividsolutions.jts.geom.Coordinate) ParseException(com.vividsolutions.jts.io.ParseException)

Example 10 with ParseException

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);
    }
}
Also used : RyaStatement(org.apache.rya.api.domain.RyaStatement) Statement(org.openrdf.model.Statement) RyaStatement(org.apache.rya.api.domain.RyaStatement) SimpleFeature(org.opengis.feature.simple.SimpleFeature) FilterFactory(org.opengis.filter.FilterFactory) Identifier(org.opengis.filter.identity.Identifier) Filter(org.opengis.filter.Filter) Literal(org.openrdf.model.Literal) ParseException(com.vividsolutions.jts.io.ParseException) DefaultFeatureCollection(org.geotools.feature.DefaultFeatureCollection) HashSet(java.util.HashSet)

Aggregations

ParseException (com.vividsolutions.jts.io.ParseException)64 Geometry (com.vividsolutions.jts.geom.Geometry)28 WKTReader (com.vividsolutions.jts.io.WKTReader)21 ConverterException (ch.ehi.ili2db.converter.ConverterException)17 RyaStatement (org.apache.rya.api.domain.RyaStatement)7 SimpleFeature (org.opengis.feature.simple.SimpleFeature)7 Statement (org.openrdf.model.Statement)7 Wkb2iox (ch.interlis.iox_j.wkb.Wkb2iox)6 IsValidOp (com.vividsolutions.jts.operation.valid.IsValidOp)6 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)6 IoxException (ch.interlis.iox.IoxException)5 MapLayer (au.org.emii.portal.menu.MapLayer)4 WKBReader (com.vividsolutions.jts.io.WKBReader)4 IOException (java.io.IOException)4 Literal (org.openrdf.model.Literal)4 Coordinate (com.vividsolutions.jts.geom.Coordinate)3 Point (com.vividsolutions.jts.geom.Point)3 Polygon (com.vividsolutions.jts.geom.Polygon)3 WKTWriter (com.vividsolutions.jts.io.WKTWriter)3 SQLException (java.sql.SQLException)3