Search in sources :

Example 1 with AttributeGeometry

use of org.commongeoregistry.adapter.dataaccess.AttributeGeometry in project geoprism-registry by terraframe.

the class RegistryVersionTest method testInsertDuplicateBetween.

/**
 * Tests to make sure if we set a value which is encompassed by a larger surrounding date range
 * that the operation is ignored.
 */
@Test
public void testInsertDuplicateBetween() throws ParseException {
    final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    dateFormat.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    this.addVersionData(FastTestDataset.PROV_CENTRAL);
    Assert.assertEquals(3, FastTestDataset.PROV_CENTRAL.getServerObject().getValuesOverTime(DefaultAttribute.EXISTS.getName()).size());
    FastTestDataset.PROV_CENTRAL.getServerObject().setExists(Boolean.TRUE, dateFormat.parse("02-10-1990"), dateFormat.parse("02-15-1990"));
    Assert.assertEquals(3, FastTestDataset.PROV_CENTRAL.getServerObject().getValuesOverTime(DefaultAttribute.EXISTS.getName()).size());
    GeoObjectOverTime goTime = testData.adapter.getGeoObjectOverTimeByCode(FastTestDataset.PROV_CENTRAL.getCode(), FastTestDataset.PROV_CENTRAL.getGeoObjectType().getCode());
    Assert.assertEquals(3, goTime.getAllValues(DefaultAttribute.EXISTS.getName()).size());
    Assert.assertEquals(FastTestDataset.PROV_CENTRAL.getCode(), goTime.getCode());
    Assert.assertEquals(Boolean.FALSE, goTime.getExists(dateFormat.parse("1990-01-01")));
    Assert.assertEquals(Boolean.TRUE, goTime.getExists(dateFormat.parse("1990-02-01")));
    Assert.assertEquals(Boolean.FALSE, goTime.getExists(dateFormat.parse("1990-03-01")));
    ValueOverTimeCollectionDTO allStatus = goTime.getAllValues(DefaultAttribute.EXISTS.getName());
    Assert.assertEquals("1990-01-01", dateFormat.format(allStatus.get(0).getStartDate()));
    Assert.assertEquals("1990-01-31", dateFormat.format(allStatus.get(0).getEndDate()));
    Assert.assertEquals("1990-02-01", dateFormat.format(allStatus.get(1).getStartDate()));
    Assert.assertEquals("1990-02-28", dateFormat.format(allStatus.get(1).getEndDate()));
    Assert.assertEquals("1990-03-01", dateFormat.format(allStatus.get(2).getStartDate()));
    Assert.assertEquals("1990-03-31", dateFormat.format(allStatus.get(2).getEndDate()));
    Geometry expectedGeom = FastTestDataset.PROV_CENTRAL.fetchGeoObject().getGeometry();
    Geometry actualGeom = ((AttributeGeometry) goTime.getAttributeOnDate(DefaultAttribute.GEOMETRY.getName(), FastTestDataset.DEFAULT_OVER_TIME_DATE)).getValue();
    Assert.assertTrue(expectedGeom.equalsTopo(actualGeom));
}
Also used : AttributeGeometry(org.commongeoregistry.adapter.dataaccess.AttributeGeometry) Geometry(com.vividsolutions.jts.geom.Geometry) ValueOverTimeCollectionDTO(org.commongeoregistry.adapter.dataaccess.ValueOverTimeCollectionDTO) AttributeGeometry(org.commongeoregistry.adapter.dataaccess.AttributeGeometry) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 2 with AttributeGeometry

use of org.commongeoregistry.adapter.dataaccess.AttributeGeometry in project geoprism-registry by terraframe.

the class RegistryVersionTest method testGetGeoObjectOverTimeByCode.

@Test
public void testGetGeoObjectOverTimeByCode() throws ParseException {
    this.addVersionData(FastTestDataset.PROV_CENTRAL);
    GeoObjectOverTime goTime = testData.adapter.getGeoObjectOverTimeByCode(FastTestDataset.PROV_CENTRAL.getCode(), FastTestDataset.PROV_CENTRAL.getGeoObjectType().getCode());
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    dateFormat.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    Assert.assertEquals(FastTestDataset.PROV_CENTRAL.getCode(), goTime.getCode());
    Assert.assertEquals(Boolean.FALSE, goTime.getExists(dateFormat.parse("1990-01-01")));
    Assert.assertEquals(Boolean.TRUE, goTime.getExists(dateFormat.parse("1990-02-01")));
    Assert.assertEquals(Boolean.FALSE, goTime.getExists(dateFormat.parse("1990-03-01")));
    ValueOverTimeCollectionDTO allStatus = goTime.getAllValues(DefaultAttribute.EXISTS.getName());
    Assert.assertEquals("1990-01-01", dateFormat.format(allStatus.get(0).getStartDate()));
    Assert.assertEquals("1990-01-31", dateFormat.format(allStatus.get(0).getEndDate()));
    Assert.assertEquals("1990-02-01", dateFormat.format(allStatus.get(1).getStartDate()));
    Assert.assertEquals("1990-02-28", dateFormat.format(allStatus.get(1).getEndDate()));
    Assert.assertEquals("1990-03-01", dateFormat.format(allStatus.get(2).getStartDate()));
    Assert.assertEquals("1990-03-31", dateFormat.format(allStatus.get(2).getEndDate()));
    Geometry expectedGeom = FastTestDataset.PROV_CENTRAL.fetchGeoObject().getGeometry();
    Geometry actualGeom = ((AttributeGeometry) goTime.getAttributeOnDate(DefaultAttribute.GEOMETRY.getName(), FastTestDataset.DEFAULT_OVER_TIME_DATE)).getValue();
    Assert.assertTrue(expectedGeom.equalsTopo(actualGeom));
}
Also used : AttributeGeometry(org.commongeoregistry.adapter.dataaccess.AttributeGeometry) Geometry(com.vividsolutions.jts.geom.Geometry) ValueOverTimeCollectionDTO(org.commongeoregistry.adapter.dataaccess.ValueOverTimeCollectionDTO) AttributeGeometry(org.commongeoregistry.adapter.dataaccess.AttributeGeometry) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Aggregations

Geometry (com.vividsolutions.jts.geom.Geometry)2 SimpleDateFormat (java.text.SimpleDateFormat)2 AttributeGeometry (org.commongeoregistry.adapter.dataaccess.AttributeGeometry)2 GeoObjectOverTime (org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)2 ValueOverTimeCollectionDTO (org.commongeoregistry.adapter.dataaccess.ValueOverTimeCollectionDTO)2 Test (org.junit.Test)2