Skip to content

Commit

Permalink
fixed GeoJSON Test
Browse files Browse the repository at this point in the history
  • Loading branch information
ttrelle committed Sep 22, 2017
1 parent b6f4af9 commit 1285880
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 0 additions & 3 deletions springdata-mongodb/src/main/java/mongodb/geo/Location.java
Expand Up @@ -2,8 +2,6 @@

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.geo.GeoJsonPoint;
import org.springframework.data.mongodb.core.index.GeoSpatialIndexType;
import org.springframework.data.mongodb.core.index.GeoSpatialIndexed;

/**
* A named location, using GeoJSON API.
Expand All @@ -13,7 +11,6 @@ public class Location {

@Id private String id;

@GeoSpatialIndexed(type = GeoSpatialIndexType.GEO_2DSPHERE)
private GeoJsonPoint position;

public Location() {}
Expand Down
Expand Up @@ -16,6 +16,9 @@
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Metrics;
import org.springframework.data.geo.Point;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.index.GeoSpatialIndexType;
import org.springframework.data.mongodb.core.index.GeospatialIndex;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

Expand All @@ -33,10 +36,17 @@ public class LocationRepositoryTest {

private static final Point DUS = new Point( 6.810036, 51.224088 );

@Autowired
private MongoTemplate template;

@Autowired
LocationRepository repo;

@Before public void setUp() {
template
.indexOps(Location.class)
.ensureIndex(new GeospatialIndex("position").typed(GeoSpatialIndexType.GEO_2DSPHERE));

// prepare data
repo.save( new Location("A", 0.001, -0.002) );
repo.save( new Location("B", 1, 1) );
Expand Down

0 comments on commit 1285880

Please sign in to comment.