Skip to content

Commit

Permalink
Fixed tests after RTree updates
Browse files Browse the repository at this point in the history
  • Loading branch information
craigtaverner committed Feb 23, 2017
1 parent c03933a commit 3839c44
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
6 changes: 0 additions & 6 deletions src/main/java/org/neo4j/gis/spatial/DefaultLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,6 @@ public void initialize(SpatialDatabaseService spatialDatabase, String name, Node

// index must be created *after* geometryEncoder
this.index = new LayerRTreeIndex(spatialDatabase.getDatabase(), this);

// try determine geometry type, might use index search to detect geometries
Integer geometryType = getGeometryType();
if (geometryType != null) {
setGeometryType(geometryType);
}
}

/**
Expand Down
20 changes: 16 additions & 4 deletions src/test/java/org/neo4j/gis/spatial/Neo4jSpatialDataStoreTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.geotools.data.ResourceInfo;
import org.geotools.data.neo4j.Neo4jSpatialDataStore;
import org.geotools.data.simple.SimpleFeatureCollection;
import org.geotools.data.simple.SimpleFeatureIterator;
import org.geotools.data.simple.SimpleFeatureSource;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.geotools.referencing.crs.DefaultGeographicCRS;
Expand All @@ -17,8 +18,11 @@
import javax.xml.stream.XMLStreamException;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.HashSet;
import java.util.Set;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertThat;

public class Neo4jSpatialDataStoreTest {
Expand Down Expand Up @@ -73,8 +77,7 @@ public void shouldBeAbleToGetFeatureSourceForLayer() throws IOException {
SimpleFeatureSource source = store.getFeatureSource("map");
SimpleFeatureCollection features = source.getFeatures();
assertThat("Expected 217 features", features.size(), equalTo(217));
SimpleFeature feature = features.features().next();
assertThat("Expected first feature to have name 'Nybrodalsvägen'", feature.getAttribute("name").toString(), equalTo("Nybrodalsvägen"));
assertThat("Expected there to be a feature with name 'Nybrodalsvägen'", featureNames(features), hasItem("Nybrodalsvägen"));
}

@Test
Expand All @@ -86,8 +89,17 @@ public void shouldBeAbleToGetInfoForLayer() throws IOException {
assertThat(bounds, equalTo(new ReferencedEnvelope(12.7856667, 13.2873561, 55.9254241, 56.2179056, DefaultGeographicCRS.WGS84)));
SimpleFeatureCollection features = source.getFeatures();
assertThat("Expected 217 features", features.size(), equalTo(217));
SimpleFeature feature = features.features().next();
assertThat("Expected first feature to have name 'Nybrodalsvägen'", feature.getAttribute("name").toString(), equalTo("Nybrodalsvägen"));
assertThat("Expected there to be a feature with name 'Nybrodalsvägen'", featureNames(features), hasItem("Nybrodalsvägen"));
}

private Set<String> featureNames(SimpleFeatureCollection features) {
HashSet<String> names = new HashSet<>();
SimpleFeatureIterator featureIterator = features.features();
while (featureIterator.hasNext()) {
SimpleFeature feature = featureIterator.next();
Object name = feature.getAttribute("name");
if (name != null) names.add(name.toString());
}
return names;
}
}

0 comments on commit 3839c44

Please sign in to comment.