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);
}
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);
}
}
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);
}
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();
}
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);
}
Aggregations