Search in sources :

Example 1 with GeometryHandler

use of org.n52.sos.util.GeometryHandler in project SOS by 52North.

the class HibernateFeatureQueryHandlerTest method setUp.

@Before
public void setUp() throws ConfigurationError {
    geometryHandler = new GeometryHandler();
    geometryHandler.setStorageEpsg(4326);
    geometryHandler.setStorage3DEpsg(4979);
    geometryHandler.setEpsgCodesWithNorthingFirstAxisOrder("2044-2045;2081-2083;2085-2086;2093;2096-2098;2105-2132;2169-2170;2176-2180;2193;2200;2206-2212;2319;" + "2320-2462;2523-2549;2551-2735;2738-2758;2935-2941;2953;3006-3030;3034-3035;3058-3059;3068;" + "3114-3118;3126-3138;3300-3301;3328-3335;3346;3350-3352;3366;3416;4001-4999;20004-20032;" + "20064-20092;21413-21423;21473-21483;21896-21899;22171;22181-22187;22191-22197;25884;27205-27232;" + "27391-27398;27492;28402-28432;28462-28492;30161-30179;30800;31251-31259;31275-31279;31281-31290;" + "31466-31700");
    geometryHandler.setDatasourceNorthingFirst(false);
    contentCacheController.setPersistenceStrategy(Mockito.mock(ContentCachePersistenceStrategy.class));
    contentCacheController.setCacheFactory(Mockito.mock(ContentCacheFactory.class));
    contentCacheController.setCompleteCacheUpdateFactory(Mockito.mock(CompleteCacheUpdateFactory.class));
    contentCacheController.setCache(cache);
    featureQueryHandler = new HibernateFeatureQueryHandler();
    featureQueryHandler.setGeometryHandler(geometryHandler);
    featureQueryHandler.setContentCacheController(contentCacheController);
    featureQueryHandler.setI18NDAORepository(i18NDAORepository);
}
Also used : CompleteCacheUpdateFactory(org.n52.iceland.cache.ctrl.CompleteCacheUpdateFactory) GeometryHandler(org.n52.sos.util.GeometryHandler) ContentCachePersistenceStrategy(org.n52.iceland.cache.ContentCachePersistenceStrategy) ContentCacheFactory(org.n52.iceland.cache.ctrl.ContentCacheFactory) Before(org.junit.Before)

Example 2 with GeometryHandler

use of org.n52.sos.util.GeometryHandler in project SOS by 52North.

the class SosCacheFeederHandler method updateCache.

@Override
public void updateCache(SosWritableContentCache cache) throws OwsExceptionReport {
    checkCacheNotNull(cache);
    List<OwsExceptionReport> errors = CollectionHelper.synchronizedList();
    Session session = null;
    try {
        InitialCacheUpdate update = new InitialCacheUpdate(this.cacheThreadCount, this.defaultLocale, this.i18NDAORepository, this.sessionStore, this.serviceMetadataRepository, geometryHandler);
        session = this.sessionStore.getSession();
        update.setCache(cache);
        update.setErrors(errors);
        update.setSession(session);
        LOGGER.info("Starting cache update");
        long cacheUpdateStartTime = System.currentTimeMillis();
        update.execute();
        logCacheLoadTime(cacheUpdateStartTime);
    } catch (Exception e) {
        LOGGER.error(ERROR_UPDATE_CACHE, e);
        errors.add(new NoApplicableCodeException().causedBy(e).withMessage(ERROR_UPDATE_CACHE));
    } finally {
        try {
            this.sessionStore.returnSession(session);
        } catch (Exception e2) {
            // TODO check why this is necessary
            LOGGER.error(ERROR_RETURNING_CONNECTION, e2);
        }
    }
    if (!errors.isEmpty()) {
        throw new CompositeOwsException(errors);
    }
}
Also used : NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) InitialCacheUpdate(org.n52.sos.ds.cache.InitialCacheUpdate) CompositeOwsException(org.n52.shetland.ogc.ows.exception.CompositeOwsException) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport) CompositeOwsException(org.n52.shetland.ogc.ows.exception.CompositeOwsException) NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) Session(org.hibernate.Session)

Example 3 with GeometryHandler

use of org.n52.sos.util.GeometryHandler in project SOS by 52North.

the class BoundingBoxEnrichmentTest method setUp.

@Before
public void setUp() throws OwsExceptionReport {
    final SosOffering sosOffering = new SosOffering("offeringIdentifier", "offeringName");
    final Collection<SosOffering> sosOfferings = Lists.newArrayList(sosOffering);
    final Envelope envelope = new Envelope(1.0, 2.0, 3.0, 4.0);
    final ReferencedEnvelope sosEnvelope = new ReferencedEnvelope(envelope, 4326);
    Mockito.when(enrichmentMock.getSosOfferings()).thenReturn(sosOfferings);
    Mockito.when(enrichmentMock.createEnvelopeForOfferings()).thenReturn(sosEnvelope);
    final ProcedureDescriptionSettings procSettMock = Mockito.mock(ProcedureDescriptionSettings.class);
    Mockito.when(procSettMock.getLatLongUom()).thenReturn("deg");
    Mockito.when(enrichmentMock.procedureSettings()).thenReturn(procSettMock);
    Mockito.doCallRealMethod().when(enrichmentMock).enrich((AbstractSensorML) ArgumentMatchers.any());
    final GeometryHandler geomHandlerMock = Mockito.mock(GeometryHandler.class);
    final AbstractProcedureCreationContext ctxMock = Mockito.mock(AbstractProcedureCreationContext.class);
    Mockito.when(ctxMock.getGeometryHandler()).thenReturn(geomHandlerMock);
    Mockito.when(geomHandlerMock.isNorthingFirstEpsgCode(sosEnvelope.getSrid())).thenReturn(true);
    Mockito.when(enrichmentMock.getProcedureCreationContext()).thenReturn(ctxMock);
}
Also used : ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) GeometryHandler(org.n52.sos.util.GeometryHandler) AbstractProcedureCreationContext(org.n52.sos.ds.procedure.AbstractProcedureCreationContext) SosOffering(org.n52.shetland.ogc.sos.SosOffering) ProcedureDescriptionSettings(org.n52.sos.service.ProcedureDescriptionSettings) ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) SweEnvelope(org.n52.shetland.ogc.swe.SweEnvelope) Envelope(org.locationtech.jts.geom.Envelope) Before(org.junit.Before)

Example 4 with GeometryHandler

use of org.n52.sos.util.GeometryHandler in project SOS by 52North.

the class AbstractInsertDAOTest method setUp.

public void setUp() throws OwsExceptionReport, ConverterException, EncodingException {
    GEOMETRY.setSRID(4326);
    SOSHibernateSessionHolder holder = new SOSHibernateSessionHolder();
    holder.setConnectionProvider(this);
    daoFactory.setSweHelper(new SweHelper());
    SosHelper sosHelper = new SosHelper();
    sosHelper.setServiceURL(URI.create("http://test.org"));
    daoFactory.setSosHelper(sosHelper);
    GeometryHandler geometryHandler = new GeometryHandler();
    initGeometryHandler(geometryHandler);
    daoFactory.setGeometryHandler(geometryHandler);
    HibernateFeatureQueryHandler featureQueryHandler = new HibernateFeatureQueryHandler();
    featureQueryHandler.setDaoFactory(daoFactory);
    featureQueryHandler.setI18NDAORepository(i18NDAORepository);
    featureQueryHandler.setGeometryHandler(geometryHandler);
    featureQueryHandler.setContentCacheController(contentCacheController);
    daoFactory.setFeatureQueryHandler(featureQueryHandler);
    daoFactory.setDecoderRepository(decoderRepository);
    daoFactory.setEncoderRepository(encoderRepository);
    daoFactory.setI18NDAORepository(i18NDAORepository);
    daoFactory.setSweHelper(initSweHelper());
    cacheFeeder.setConnectionProvider(holder);
    cacheFeeder.setI18NDAORepository(i18NDAORepository);
    cacheFeeder.setGeometryHandler(geometryHandler);
    initEncoder();
    initDecoder();
    bindingRepository.setComponentFactories(Optional.empty());
    bindingRepository.setComponents(Optional.empty());
    additionalObservationCreatorRepository.setComponentFactories(Optional.empty());
    additionalObservationCreatorRepository.setComponents(Optional.empty());
    contentCacheController.setPersistenceStrategy(Mockito.mock(ContentCachePersistenceStrategy.class));
    contentCacheController.setCacheFactory(Mockito.mock(ContentCacheFactory.class));
    contentCacheController.setCompleteCacheUpdateFactory(Mockito.mock(CompleteCacheUpdateFactory.class));
    contentCacheController.setCache(cache);
    cache.setSupportedTypeRepository(Mockito.mock(SupportedTypeRepository.class));
    i18NDAORepository.init();
    decoderRepository.init();
    converterRepository.init();
    factoryRepository.init();
    bindingRepository.init();
    additionalObservationCreatorRepository.init();
    DefaultContentModificationListener defaultContentModificationListener = new DefaultContentModificationListener(cacheFeeder, contentCacheController);
    defaultContentModificationListener.setConverterRepository(converterRepository);
    serviceEventBus.register(defaultContentModificationListener);
    ctx = new HibernateProcedureCreationContext(serviceMetadataRepository, decoderRepository, factoryRepository, i18NDAORepository, daoFactory, converterRepository, null, bindingRepository, null, contentCacheController, Mockito.mock(ProcedureDescriptionSettings.class));
    observationCtx = new OmObservationCreatorContext(serviceMetadataRepository, i18NDAORepository, daoFactory, new ProfileHanlderMock(), additionalObservationCreatorRepository, contentCacheController, featureQueryHandler, converterRepository, factoryRepository, geometryHandler, decoderRepository, null, bindingRepository);
    observationCtx.setDefaultLanguage("eng");
    Session session = null;
    try {
        session = getSession();
        HibernateMetadataCache.init(session);
    } finally {
        returnSession(session);
    }
    initDaos();
}
Also used : CompleteCacheUpdateFactory(org.n52.iceland.cache.ctrl.CompleteCacheUpdateFactory) GeometryHandler(org.n52.sos.util.GeometryHandler) OmObservationCreatorContext(org.n52.sos.ds.hibernate.util.observation.OmObservationCreatorContext) ContentCachePersistenceStrategy(org.n52.iceland.cache.ContentCachePersistenceStrategy) HibernateProcedureCreationContext(org.n52.sos.ds.hibernate.util.procedure.HibernateProcedureCreationContext) SupportedTypeRepository(org.n52.iceland.coding.SupportedTypeRepository) DefaultContentModificationListener(org.n52.sos.cache.ctrl.DefaultContentModificationListener) SOSHibernateSessionHolder(org.n52.series.db.da.sos.SOSHibernateSessionHolder) SosHelper(org.n52.sos.util.SosHelper) ContentCacheFactory(org.n52.iceland.cache.ctrl.ContentCacheFactory) SweHelper(org.n52.svalbard.util.SweHelper) Session(org.hibernate.Session)

Example 5 with GeometryHandler

use of org.n52.sos.util.GeometryHandler in project SOS by 52North.

the class SosCacheFeederDAOTest method initCacheFeeder.

@Before
public void initCacheFeeder() {
    instance = new SosCacheFeederHandler();
    SOSHibernateSessionHolder holder = new SOSHibernateSessionHolder();
    holder.setConnectionProvider(this);
    instance.setConnectionProvider(holder);
    GeometryHandler geometryHandler = new GeometryHandler();
    geometryHandler.setAuthority("EPSG");
    geometryHandler.setStorageEpsg(4326);
    geometryHandler.setSpatialDatasource(true);
    geometryHandler.init();
    instance.setGeometryHandler(geometryHandler);
}
Also used : GeometryHandler(org.n52.sos.util.GeometryHandler) SosCacheFeederHandler(org.n52.sos.ds.SosCacheFeederHandler) SOSHibernateSessionHolder(org.n52.series.db.da.sos.SOSHibernateSessionHolder) Before(org.junit.Before)

Aggregations

GeometryHandler (org.n52.sos.util.GeometryHandler)4 Before (org.junit.Before)3 Session (org.hibernate.Session)2 ContentCachePersistenceStrategy (org.n52.iceland.cache.ContentCachePersistenceStrategy)2 CompleteCacheUpdateFactory (org.n52.iceland.cache.ctrl.CompleteCacheUpdateFactory)2 ContentCacheFactory (org.n52.iceland.cache.ctrl.ContentCacheFactory)2 SOSHibernateSessionHolder (org.n52.series.db.da.sos.SOSHibernateSessionHolder)2 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)2 Envelope (org.locationtech.jts.geom.Envelope)1 Geometry (org.locationtech.jts.geom.Geometry)1 ParseException (org.locationtech.jts.io.ParseException)1 Setting (org.n52.faroe.annotation.Setting)1 SupportedTypeRepository (org.n52.iceland.coding.SupportedTypeRepository)1 Range (org.n52.iceland.util.Range)1 CompositeOwsException (org.n52.shetland.ogc.ows.exception.CompositeOwsException)1 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)1 SosOffering (org.n52.shetland.ogc.sos.SosOffering)1 SweEnvelope (org.n52.shetland.ogc.swe.SweEnvelope)1 ReferencedEnvelope (org.n52.shetland.util.ReferencedEnvelope)1 DefaultContentModificationListener (org.n52.sos.cache.ctrl.DefaultContentModificationListener)1