Skip to content

Commit

Permalink
fix checkstyle warnings in oshdb-util tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joker234 committed Nov 3, 2020
1 parent b232f77 commit caeefa3
Show file tree
Hide file tree
Showing 38 changed files with 1,103 additions and 1,045 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,14 @@ public static void breakDownClass() throws SQLException {
IterateAllTest.conn.close();
}

public IterateAllTest() {}
public IterateAllTest() {
}

@Test
public void testIssue108() throws SQLException, IOException, ClassNotFoundException, ParseException, OSHDBKeytablesNotFoundException {
ResultSet oshCellsRawData = conn.prepareStatement("select data from " + TableNames.T_NODES).executeQuery();
public void testIssue108() throws SQLException, IOException, ClassNotFoundException,
ParseException, OSHDBKeytablesNotFoundException {
ResultSet oshCellsRawData = conn.prepareStatement(
"select data from " + TableNames.T_NODES).executeQuery();

int countTotal = 0;
int countCreated = 0;
Expand Down Expand Up @@ -78,10 +81,11 @@ public void testIssue108() throws SQLException, IOException, ClassNotFoundExcept
).collect(Collectors.toList());
countTotal += result.size();
for (IterateAllEntry entry : result) {
if (entry.activities.contains(ContributionType.CREATION))
if (entry.activities.contains(ContributionType.CREATION)) {
countCreated++;
else
} else {
countOther++;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package org.heigit.bigspatialdata.oshdb.util.celliterator;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;

import java.io.IOException;
import java.util.EnumSet;
import java.util.List;
Expand All @@ -20,10 +24,6 @@
import org.locationtech.jts.geom.Point;
import org.locationtech.jts.geom.Polygon;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;

public class IterateByContributionNodesTest {
private GridOSHNodes oshdbDataGridCell;
private final OSMXmlReader osmXmlTestData = new OSMXmlReader();
Expand Down Expand Up @@ -412,13 +412,13 @@ public void testTagChangeTagFilterWithoutSuccess() {
@Test
public void testPolygonIntersectingDataPartly() {
// lon lat changes, so that node in v2 is outside bbox
GeometryFactory geometryFactory = new GeometryFactory();
Coordinate[] coords=new Coordinate[5];
coords[0]=new Coordinate(10.8,10.3);
coords[1]=new Coordinate(10.8 ,22.7);
coords[2]=new Coordinate(22.7,22.7);
coords[3]=new Coordinate(22.7,10.3);
coords[4]=new Coordinate(10.8,10.3);
final GeometryFactory geometryFactory = new GeometryFactory();
Coordinate[] coords = new Coordinate[5];
coords[0] = new Coordinate(10.8,10.3);
coords[1] = new Coordinate(10.8,22.7);
coords[2] = new Coordinate(22.7,22.7);
coords[3] = new Coordinate(22.7,10.3);
coords[4] = new Coordinate(10.8,10.3);
Polygon polygonFromCoordinates = geometryFactory.createPolygon(coords);

List<IterateAllEntry> result = (new CellIterator(
Expand All @@ -440,13 +440,14 @@ public void testPolygonIntersectingDataPartly() {
@Test
public void testTagFilterAndPolygonIntersectingDataPartly() {
// lon lat changes, so that node in v2 is outside bbox
GeometryFactory geometryFactory = new GeometryFactory(); // create clipping polygon for area of interest
Coordinate[] coords=new Coordinate[5];
coords[0]=new Coordinate(10.8,10.3);
coords[1]=new Coordinate(10.8 ,22.7);
coords[2]=new Coordinate(22.7,22.7);
coords[3]=new Coordinate(22.7,10.3);
coords[4]=new Coordinate(10.8,10.3);
final GeometryFactory geometryFactory = new GeometryFactory();
// create clipping polygon for area of interest
Coordinate[] coords = new Coordinate[5];
coords[0] = new Coordinate(10.8,10.3);
coords[1] = new Coordinate(10.8,22.7);
coords[2] = new Coordinate(22.7,22.7);
coords[3] = new Coordinate(22.7,10.3);
coords[4] = new Coordinate(10.8,10.3);
Polygon polygonFromCoordinates = geometryFactory.createPolygon(coords);

List<IterateAllEntry> result = (new CellIterator(
Expand All @@ -457,24 +458,25 @@ public void testTagFilterAndPolygonIntersectingDataPartly() {
polygonFromCoordinates,// clipping polygon
areaDecider,
oshEntity -> oshEntity.getId() == 6,
osmEntity -> osmEntity.hasTagKey(osmXmlTestData.keys().get("shop")),// filter entity for tag = shop
// filter entity for tag = shop
osmEntity -> osmEntity.hasTagKey(osmXmlTestData.keys().get("shop")),
false
)).iterateByContribution(
oshdbDataGridCell
).collect(Collectors.toList());
// result size =2 becuase if tag filtered for disappears it's a deletion
assertEquals(2,result.size());// one version with tag shop
assertEquals(2,result.size()); // one version with tag shop
}

@Test
public void testCoordinatesRelativeToPolygon() throws IOException {
//different cases of relative position between node coordinate(s) and cell bbox / query polygon
GeometryFactory geometryFactory = new GeometryFactory();
Coordinate[] coords=new Coordinate[4];
coords[0]=new Coordinate(0.0,0.0);
coords[1]=new Coordinate(1.5,0.0);
coords[2]=new Coordinate(0.0,1.5);
coords[3]=new Coordinate(0.0,0.0);
// different cases of relative position between node coordinate(s) and cell bbox / query polygon
final GeometryFactory geometryFactory = new GeometryFactory();
Coordinate[] coords = new Coordinate[4];
coords[0] = new Coordinate(0.0,0.0);
coords[1] = new Coordinate(1.5,0.0);
coords[2] = new Coordinate(0.0,1.5);
coords[3] = new Coordinate(0.0,0.0);
Polygon polygonFromCoordinates = geometryFactory.createPolygon(coords);

List<IterateAllEntry> result = (new CellIterator(
Expand All @@ -487,9 +489,8 @@ public void testCoordinatesRelativeToPolygon() throws IOException {
oshEntity -> oshEntity.getId() >= 10 && oshEntity.getId() < 20,
osmEntity -> true,
false
)).iterateByContribution(
GridOSHFactory.getGridOSHNodes(osmXmlTestData, 6, (new XYGrid(6)).getId(1.0, 1.0)/* approx. 0,0,5.6,5.6*/)
).collect(Collectors.toList());
)).iterateByContribution(GridOSHFactory.getGridOSHNodes(osmXmlTestData, 6, (new XYGrid(6))
.getId(1.0, 1.0)/* approx. 0,0,5.6,5.6*/)).collect(Collectors.toList());

assertEquals(2, result.size());
assertTrue(result.get(0).osmEntity.getId() == 13);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.heigit.bigspatialdata.oshdb.util.celliterator;

import static org.junit.Assert.assertTrue;

import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.Collections;
Expand All @@ -18,14 +20,12 @@
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.Polygon;

import static org.junit.Assert.assertTrue;

public class IterateByContributionNotOsmTypeSpecificTest {

private final OSMXmlReader osmXmlTestData = new OSMXmlReader();
TagInterpreter areaDecider;
private final List<OSHRelation> oshRelations;
private final double DELTA = 1E-6;
private static final double DELTA = 1E-6;

public IterateByContributionNotOsmTypeSpecificTest() throws IOException {
osmXmlTestData.add("./src/test/resources/different-timestamps/polygon.osm");
Expand All @@ -36,16 +36,16 @@ public IterateByContributionNotOsmTypeSpecificTest() throws IOException {

@Test
public void testCellOutsidePolygon() throws IOException {
GridOSHRelations oshdbDataGridCell = GridOSHRelations.compact(69120, 12, 0, 0, 0, 0, Collections
.emptyList());

GeometryFactory geometryFactory = new GeometryFactory();
Coordinate[] coords=new Coordinate[5];
coords[0]=new Coordinate(10.8,10.3);
coords[1]=new Coordinate(10.8 ,12.7);
coords[2]=new Coordinate(12.7,12.7);
coords[3]=new Coordinate(12.7,10.3);
coords[4]=new Coordinate(10.8,10.3);
final GridOSHRelations oshdbDataGridCell = GridOSHRelations.compact(69120, 12, 0, 0, 0, 0,
Collections.emptyList());

final GeometryFactory geometryFactory = new GeometryFactory();
Coordinate[] coords = new Coordinate[5];
coords[0] = new Coordinate(10.8,10.3);
coords[1] = new Coordinate(10.8,12.7);
coords[2] = new Coordinate(12.7,12.7);
coords[3] = new Coordinate(12.7,10.3);
coords[4] = new Coordinate(10.8,10.3);
Polygon polygonFromCoordinates = geometryFactory.createPolygon(coords);

List<IterateAllEntry> resultPoly = (new CellIterator(
Expand All @@ -63,17 +63,19 @@ public void testCellOutsidePolygon() throws IOException {
).collect(Collectors.toList());
assertTrue(resultPoly.isEmpty());
}

@Test
public void testCellCoveringPolygon() throws IOException {
GridOSHRelations oshdbDataGridCell = GridOSHRelations.compact(0, 0, 0, 0, 0, 0, oshRelations);
final GridOSHRelations oshdbDataGridCell = GridOSHRelations.compact(0, 0, 0, 0, 0, 0,
oshRelations);

GeometryFactory geometryFactory = new GeometryFactory();
final GeometryFactory geometryFactory = new GeometryFactory();

Coordinate[] coords=new Coordinate[4];
coords[0]=new Coordinate(10.8,10.3);
coords[1]=new Coordinate(12.7,12.7);
coords[2]=new Coordinate(12.7,10.3);
coords[3]=new Coordinate(10.8,10.3);
Coordinate[] coords = new Coordinate[4];
coords[0] = new Coordinate(10.8,10.3);
coords[1] = new Coordinate(12.7,12.7);
coords[2] = new Coordinate(12.7,10.3);
coords[3] = new Coordinate(10.8,10.3);
Polygon polygonFromCoordinates = geometryFactory.createPolygon(coords);

List<IterateAllEntry> resultPoly = (new CellIterator(
Expand All @@ -94,16 +96,17 @@ public void testCellCoveringPolygon() throws IOException {

@Test
public void testCellFullyInsidePolygon() throws IOException {
GridOSHRelations oshdbDataGridCell = GridOSHRelations.compact(69120, 12, 0, 0, 0, 0, oshRelations);
final GridOSHRelations oshdbDataGridCell = GridOSHRelations.compact(69120, 12, 0, 0, 0, 0,
oshRelations);

GeometryFactory geometryFactory = new GeometryFactory();
final GeometryFactory geometryFactory = new GeometryFactory();

Coordinate[] coords=new Coordinate[5];
coords[0]=new Coordinate(-180,-90);
coords[1]=new Coordinate(180 ,-90);
coords[2]=new Coordinate(180,90);
coords[3]=new Coordinate(-180,90);
coords[4]=new Coordinate(-180,-90);
Coordinate[] coords = new Coordinate[5];
coords[0] = new Coordinate(-180,-90);
coords[1] = new Coordinate(180,-90);
coords[2] = new Coordinate(180,90);
coords[3] = new Coordinate(-180,90);
coords[4] = new Coordinate(-180,-90);
Polygon polygonFromCoordinates = geometryFactory.createPolygon(coords);

List<IterateAllEntry> resultPoly = (new CellIterator(
Expand Down
Loading

0 comments on commit caeefa3

Please sign in to comment.