com.mongodb.client.model.geojson.Position Java Examples

The following examples show how to use com.mongodb.client.model.geojson.Position. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GeoEntitiesTest.java    From morphia with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldRetrieveGeoJsonPolygon() {
    // given
    Area area = new Area("The Area", new Polygon(asList(
        new Position(2.0, 1.1),
        new Position(3.5, 2.3),
        new Position(1.0, 3.7),
        new Position(2.0, 1.1))));
    getDs().save(area);

    // when
    Area found = getDs().find(Area.class)
                        .filter(eq("name", "The Area")).iterator(new FindOptions().limit(1))
                        .tryNext();

    // then
    assertThat(found, is(notNullValue()));
    assertThat(found, is(area));
}
 
Example #2
Source File: GeoQueriesTest.java    From morphia with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldFindCitiesCloseToAGivenPointWithinARadiusOfMeters() {
    // given
    double latitude = 51.5286416;
    double longitude = -0.1015987;
    Datastore datastore = getDs();
    City london = new City("London", new Point(new Position(latitude, longitude)));
    datastore.save(london);
    City manchester = new City("Manchester", new Point(new Position(53.4722454, -2.2235922)));
    datastore.save(manchester);
    City sevilla = new City("Sevilla", new Point(new Position(37.3753708, -5.9550582)));
    datastore.save(sevilla);

    getDs().ensureIndexes();

    // when
    List<City> cities = datastore.find(City.class)
                                 .filter(near("location", new Point(new Position(latitude, longitude)))
                                             .maxDistance(200000.0)).iterator()
                                 .toList();

    // then
    assertThat(cities.size(), is(1));
    assertThat(cities.get(0), is(london));
}
 
Example #3
Source File: GeoWithinQueriesWithMultiPolygonTest.java    From morphia with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldFindCitiesInEurope() {
    City manchester = new City("Manchester", new Point(new Position(53.4722454, -2.2235922)));
    getDs().save(manchester);
    City london = new City("London", new Point(new Position(51.5286416, -0.1015987)));
    getDs().save(london);
    City sevilla = new City("Sevilla", new Point(new Position(37.3753708, -5.9550582)));
    getDs().save(sevilla);
    City newYork = new City("New York", new Point(new Position(40.75981395319104, -73.98302106186748)));
    getDs().save(newYork);

    getDs().ensureIndexes();

    // when
    List<City> citiesInTheUK;
    citiesInTheUK = getDs().find(City.class)
                           .filter(geoWithin("location", europeanCountries)).iterator().toList();

    // then
    assertThat(citiesInTheUK.size(), is(3));
    assertThat(citiesInTheUK, containsInAnyOrder(london, manchester, sevilla));
}
 
Example #4
Source File: TestGeoQueries.java    From morphia with Apache License 2.0 6 votes vote down vote up
@Test
public void testNearMaxDistance() {
    getDs().getMapper().map(Place.class);
    getDs().ensureIndexes();
    final Place place1 = new Place("place1", new double[]{1, 1});
    getDs().save(place1);
    FindOptions options = new FindOptions()
                              .logQuery()
                              .limit(1);
    Query<Place> query = getDs().find(Place.class)
                                .filter(near("loc", new Point(new Position(1, 1)))
                                            .maxDistance(2.0));
    Place found = query.iterator(options).tryNext();
    Assert.assertNotNull(getDs().getLoggedQuery(options), found);

    final Place notFound = getDs().find(Place.class)
                                  .filter(near("loc", new Point(new Position(0, 0)))
                                              .maxDistance(1.0)).iterator(options)
                                  .tryNext();
    Assert.assertNull(getDs().getLoggedQuery(options), notFound);
}
 
Example #5
Source File: GeoIntersectsQueriesWithLineTest.java    From morphia with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldFindAPointThatLiesOnTheQueryLine() {
    // given
    LineString spanishLine = new LineString(asList(
        new Position(37.40759155713022, -5.964911067858338),
        new Position(37.3753708, -5.9550582)));
    City manchester = new City("Manchester", new Point(new Position(53.4722454, -2.2235922)));
    getDs().save(manchester);
    City london = new City("London", new Point(new Position(51.5286416, -0.1015987)));
    getDs().save(london);
    City sevilla = new City("Sevilla", new Point(new Position(37.3753708, -5.9550582)));
    getDs().save(sevilla);

    getDs().ensureIndexes();

    // when
    MongoCursor<City> matchingCity = getDs().find(City.class)
                                            .filter(geoIntersects("location", spanishLine)).iterator();

    // then
    assertThat(matchingCity.next(), is(sevilla));
    assertFalse(matchingCity.hasNext());
}
 
Example #6
Source File: GeoIntersectsQueriesWithPointTest.java    From morphia with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldFindAPointThatExactlyMatchesTheQueryPoint() {
    // given
    Point coordsOfManchester = new Point(new Position(53.4722454, -2.2235922));
    City manchester = new City("Manchester", coordsOfManchester);
    getDs().save(manchester);
    City london = new City("London", new Point(new Position(51.5286416, -0.1015987)));
    getDs().save(london);
    City sevilla = new City("Sevilla", new Point(new Position(37.3753708, -5.9550582)));
    getDs().save(sevilla);

    getDs().ensureIndexes();

    // when
    List<City> matchingCity = getDs().find(City.class)
                                     .filter(geoIntersects("location", coordsOfManchester)).iterator().toList();

    // then
    assertThat(matchingCity.size(), is(1));
    assertThat(matchingCity.get(0), is(manchester));
}
 
Example #7
Source File: GeoIntersectsQueriesWithPolygonTest.java    From morphia with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldFindAPointThatLiesInAQueryPolygon() {
    // given
    City manchester = new City("Manchester", new Point(new Position(53.4722454, -2.2235922)));
    getDs().save(manchester);
    City london = new City("London", new Point(new Position(51.5286416, -0.1015987)));
    getDs().save(london);
    City sevilla = new City("Sevilla", new Point(new Position(37.4057731, -5.966287)));
    getDs().save(sevilla);

    getDs().ensureIndexes();

    // when
    List<City> matchingCity = getDs().find(City.class)
                                     .filter(geoIntersects("location", new Polygon(asList(
                                         new Position(37.40759155713022, -5.964911067858338),
                                         new Position(37.40341208875179, -5.9643941558897495),
                                         new Position(37.40297396667302, -5.970452763140202),
                                         new Position(37.40759155713022, -5.964911067858338))))).iterator().toList();

    // then
    assertThat(matchingCity.size(), is(1));
    assertThat(matchingCity.get(0), is(sevilla));
}
 
Example #8
Source File: GeoWithinQueriesWithPolygonTest.java    From morphia with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldFindCitiesInTheUK() {
    // given
    Polygon uk = new Polygon(asList(new Position(49.78, -10.5),
        new Position(49.78, 1.78),
        new Position(59, 1.78),
        new Position(59, -10.5),
        new Position(49.78, -10.5)));
    City manchester = new City("Manchester", new Point(new Position(53.4722454, -2.2235922)));
    getDs().save(manchester);
    City london = new City("London", new Point(new Position(51.5286416, -0.1015987)));
    getDs().save(london);
    City sevilla = new City("Sevilla", new Point(new Position(37.3753708, -5.9550582)));
    getDs().save(sevilla);

    getDs().ensureIndexes();

    // when
    List<City> citiesInTheUK = getDs().find(City.class)
                                      .filter(geoWithin("location", uk)).iterator().toList();

    // then
    assertThat(citiesInTheUK.size(), is(2));
    assertThat(citiesInTheUK, contains(london, manchester));
}
 
Example #9
Source File: GeoEntitiesTest.java    From morphia with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldRetrieveGeoJsonMultiPoint() {
    // given
    String name = "My stores";
    Stores stores = new Stores(name, new MultiPoint(asList(
        new Position(1, 2),
        new Position(3, 5),
        new Position(19, 13))));
    getDs().save(stores);

    // when
    Stores found = getDs().find(Stores.class).filter(eq("name", name)).iterator(new FindOptions().limit(1)).tryNext();

    // then
    assertThat(found, is(notNullValue()));
    assertThat(found, is(stores));
}
 
Example #10
Source File: GeoEntitiesTest.java    From morphia with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldRetrieveGeoJsonMultiLineString() {
    // given
    String name = "Many Paths";
    Paths paths = new Paths(name, new MultiLineString(
        asList(
            asList(
                new Position(1, 2),
                new Position(3, 5),
                new Position(19, 13)),

            asList(
                new Position(1.5, 2.0),
                new Position(1.9, 2.0),
                new Position(1.9, 1.8),
                new Position(1.5, 2.0)))));
    
    getDs().save(paths);

    // when
    Paths found = getDs().find(Paths.class).filter(eq("name", name)).iterator(new FindOptions().limit(1)).tryNext();

    // then
    assertThat(found, is(notNullValue()));
    assertThat(found, is(paths));
}
 
Example #11
Source File: GeoEntitiesTest.java    From morphia with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldRetrieveGeoJsonLineString() {
    // given
    Route route = new Route("My Route", new LineString(asList(
        new Position(1, 2),
        new Position(3, 5),
        new Position(19, 13))));
    getDs().save(route);

    // when
    Route found = getDs().find(Route.class)
                         .filter(eq("name", "My Route")).iterator(new FindOptions().limit(1)).tryNext();

    // then
    assertThat(found, is(notNullValue()));
    assertThat(found, is(route));
}
 
Example #12
Source File: TestGeoQueries.java    From morphia with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithinOutsideRadius() {
    getDs().ensureIndexes();
    final Place place1 = new Place("place1", new double[]{1, 1});
    getDs().save(place1);
    final Place found = getDs().find(Place.class)
                               .filter(center("loc", new Point(new Position(2, 2)), 0.4)).iterator(new FindOptions().limit(1))
                               .tryNext();
    Assert.assertNull(found);
}
 
Example #13
Source File: TestGeoQueries.java    From morphia with Apache License 2.0 5 votes vote down vote up
@Test
public void testGeoWithinBox() {
    getDs().ensureIndexes();
    final Place place1 = new Place("place1", new double[]{1, 1});
    getDs().save(place1);
    final Place found = getDs().find(Place.class)
                               .filter(box("loc", new Point(new Position(0, 0)), new Point(new Position(2, 2))))
                               .iterator(new FindOptions().limit(1))
                               .next();
    Assert.assertNotNull(found);
}
 
Example #14
Source File: TestGeoQueries.java    From morphia with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithinOutsideBox() {
    getDs().ensureIndexes();
    final Place place1 = new Place("place1", new double[]{1, 1});
    getDs().save(place1);
    final Place found = getDs().find(Place.class)
                               .filter(box("loc",
                                   new Point(new Position(0, 0)),
                                   new Point(new Position(.4, .5)))).iterator(new FindOptions().limit(1))
                               .tryNext();
    Assert.assertNull(found);
}
 
Example #15
Source File: TestGeoQueries.java    From morphia with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithinBox() {
    getDs().ensureIndexes();
    final Place place1 = new Place("place1", new double[]{1, 1});
    getDs().save(place1);
    final Place found = getDs().find(Place.class)
                               .filter(box("loc",
                                   new Point(new Position(0, 0)),
                                   new Point(new Position(2, 2)))).iterator(new FindOptions().limit(1))
                               .next();
    Assert.assertNotNull(found);
}
 
Example #16
Source File: TestGeoQueries.java    From morphia with Apache License 2.0 5 votes vote down vote up
@Test(expected = MongoQueryException.class)
public void testNearNoIndex() {
    final Place place1 = new Place("place1", new double[]{1, 1});
    getDs().save(place1);
    Place found = getDs().find(Place.class)
                         .filter(near("loc", new Point(new Position(0, 0)))).iterator(new FindOptions().limit(1))
                         .tryNext();
    Assert.assertNull(found);
}
 
Example #17
Source File: TestGeoQueries.java    From morphia with Apache License 2.0 5 votes vote down vote up
@Test
public void testNear() {
    getDs().ensureIndexes();
    final Place place1 = new Place("place1", new double[]{1, 1});
    getDs().save(place1);
    final Place found = getDs().find(Place.class)
                               .filter(near("loc", new Point(new Position(0, 0)))).iterator(new FindOptions().limit(1))
                               .next();
    Assert.assertNotNull(found);
}
 
Example #18
Source File: GeoIntersectsQueriesWithPointTest.java    From morphia with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldFindRoutesThatAGivenPointIsOn() {
    // given
    Route sevilla = new Route("Spain", new LineString(asList(
        new Position(37.40759155713022, -5.964911067858338),
        new Position(37.40341208875179, -5.9643941558897495),
        new Position(37.40297396667302, -5.970452763140202))));
    getDs().save(sevilla);
    Route newYork = new Route("New York", new LineString(asList(
        new Position(40.75981395319104, -73.98302106186748),
        new Position(40.7636824529618, -73.98049869574606),
        new Position(40.76962974853814, -73.97964206524193))));
    getDs().save(newYork);
    Route london = new Route("London", new LineString(asList(
        new Position(51.507780365645885, -0.21786745637655258),
        new Position(51.50802478194237, -0.21474729292094707),
        new Position(51.5086863655597, -0.20895397290587425))));
    getDs().save(london);
    Route londonToParis = new Route("London To Paris", new LineString(asList(
        new Position(51.5286416, -0.1015987),
        new Position(48.858859, 2.3470599))));
    getDs().save(londonToParis);
    getDs().ensureIndexes();

    // when
    List<Route> routeContainingPoint = getDs().find(Route.class)
                                              .filter(geoIntersects("route",
                                                  new Point(new Position(37.40759155713022, -5.964911067858338)))).iterator()
                                              .toList();

    // then
    assertThat(routeContainingPoint.size(), is(1));
    assertThat(routeContainingPoint.get(0), is(sevilla));
}
 
Example #19
Source File: TestGeoQueries.java    From morphia with Apache License 2.0 5 votes vote down vote up
@Test
public void testGeoWithinPolygon() {
    getDs().ensureIndexes();
    final Place place1 = new Place("place1", new double[]{0, 1});
    getDs().save(place1);
    final Place found = getDs().find(Place.class)
                               .filter(polygon("loc",
                                   new Point(new Position(0, 0)),
                                   new Point(new Position(0, 5)),
                                   new Point(new Position(2, 3)),
                                   new Point(new Position(2, 0)))).iterator(new FindOptions().limit(1))
                               .next();
    Assert.assertNotNull(found);
}
 
Example #20
Source File: TestGeoQueries.java    From morphia with Apache License 2.0 5 votes vote down vote up
@Test
public void testGeoWithinPolygon2() {
    getDs().ensureIndexes();
    final Place place1 = new Place("place1", new double[]{10, 1});
    getDs().save(place1);
    final Place found = getDs().find(Place.class)
                               .filter(polygon("loc",
                                   new Point(new Position(0, 0)),
                                   new Point(new Position(0, 5)),
                                   new Point(new Position(2, 3)),
                                   new Point(new Position(2, 0)))).iterator(new FindOptions().limit(1))
                               .tryNext();
    Assert.assertNull(found);
}
 
Example #21
Source File: TestGeoQueries.java    From morphia with Apache License 2.0 5 votes vote down vote up
@Test
public void testGeoWithinOutsideBox() {
    getDs().ensureIndexes();
    final Place place1 = new Place("place1", new double[]{1, 1});
    getDs().save(place1);
    final Place found = getDs().find(Place.class)
                               .filter(box("loc", new Point(new Position(0, 0)), new Point(new Position(.4, .5))))
                               .iterator(new FindOptions().limit(1))
                               .tryNext();
    Assert.assertNull(found);
}
 
Example #22
Source File: TestGeoQueries.java    From morphia with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithinRadius() {
    getDs().ensureIndexes();
    final Place place1 = new Place("place1", new double[]{1, 1});
    getDs().save(place1);
    final Place found = getDs().find(Place.class)
                               .filter(center("loc", new Point(new Position(0, 1)), 1.1)).iterator(new FindOptions().limit(1))
                               .next();
    Assert.assertNotNull(found);
}
 
Example #23
Source File: TestGeoQueries.java    From morphia with Apache License 2.0 5 votes vote down vote up
@Test
public void testGeoWithinRadiusSphere() {
    getDs().ensureIndexes();
    final Place place1 = new Place("place1", new double[]{1, 1});
    getDs().save(place1);
    final Place found = getDs().find(Place.class)
                               .filter(centerSphere("loc", new Point(new Position(0, 1)), 1)).iterator(new FindOptions().limit(1))
                               .next();
    Assert.assertNotNull(found);
}
 
Example #24
Source File: TestGeoQueries.java    From morphia with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithinRadius2() {
    getDs().ensureIndexes();
    final Place place1 = new Place("place1", new double[]{1, 1});
    getDs().save(place1);
    final Place found = getDs().find(Place.class)
                               .filter(center("loc", new Point(new Position(0.5, 0.5)), 0.77)).iterator(new FindOptions().limit(1))
                               .next();
    Assert.assertNotNull(found);
}
 
Example #25
Source File: TestGeoQueries.java    From morphia with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithinRadiusSphere() {
    getDs().ensureIndexes();
    final Place place1 = new Place("place1", new double[]{1, 1});
    getDs().save(place1);
    final Place found = getDs().find(Place.class)
                               .filter(centerSphere("loc", new Point(new Position(0, 1)), 1)).iterator(new FindOptions().limit(1))
                               .next();
    Assert.assertNotNull(found);
}
 
Example #26
Source File: GeoNearQueriesTest.java    From morphia with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldFindRoutesOrderedByDistanceFromAGivenPoint() {
    // given
    Route sevilla = new Route("Spain", new LineString(asList(new Position(37.40759155713022, -5.964911067858338),
        new Position(37.40341208875179, -5.9643941558897495),
        new Position(37.40297396667302, -5.970452763140202))));
    getDs().save(sevilla);
    Route newYork = new Route("New York", new LineString(asList(new Position(40.75981395319104, -73.98302106186748),
        new Position(40.7636824529618, -73.98049869574606),
        new Position(40.76962974853814, -73.97964206524193))));
    getDs().save(newYork);
    Route london = new Route("London", new LineString(asList(new Position(51.507780365645885, -0.21786745637655258),
        new Position(51.50802478194237, -0.21474729292094707),
        new Position(51.5086863655597, -0.20895397290587425))));
    getDs().save(london);
    getDs().ensureIndexes();

    // when
    List<Route> routes = getDs().find(Route.class)
                                .filter(near("route", new Point(new Position(51.5286416, -0.1015987)))).iterator()
                                .toList();

    // then
    assertThat(routes.size(), is(3));
    assertThat(routes.get(0), is(london));
    assertThat(routes.get(1), is(sevilla));
    assertThat(routes.get(2), is(newYork));
}
 
Example #27
Source File: GeoNearQueriesTest.java    From morphia with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldFindRoutesCloseToAGivenPointWithinARadiusOfMeters() {
    // given
    Route sevilla = new Route("Spain", new LineString(asList(
        new Position(37.40759155713022, -5.964911067858338),
        new Position(37.40341208875179, -5.9643941558897495),
        new Position(37.40297396667302, -5.970452763140202))));
    getDs().save(sevilla);
    Route newYork = new Route("New York", new LineString(asList(
        new Position(40.75981395319104, -73.98302106186748),
        new Position(40.7636824529618, -73.98049869574606),
        new Position(40.76962974853814, -73.97964206524193))));
    getDs().save(newYork);
    Route london = new Route("London", new LineString(asList(
        new Position(51.507780365645885, -0.21786745637655258),
        new Position(51.50802478194237, -0.21474729292094707),
        new Position(51.5086863655597, -0.20895397290587425))));
    getDs().save(london);
    getDs().ensureIndexes();

    // when
    List<Route> routes = getDs().find(Route.class)
                                .filter(near("route", new Point(new Position(51.5286416, -0.1015987)))
                                            .maxDistance(20000.0)).iterator()
                                .toList();

    // then
    assertThat(routes.size(), is(1));
    assertThat(routes.get(0), is(london));
}
 
Example #28
Source File: GeoIntersectsQueriesWithPolygonTest.java    From morphia with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldFindAreasThatAPolygonIntersects() {
    // given
    Area sevilla = new Area("Spain",
        new Polygon(asList(new Position(37.40759155713022, -5.964911067858338),
            new Position(37.40341208875179, -5.9643941558897495),
            new Position(37.40297396667302, -5.970452763140202),
            new Position(37.40759155713022, -5.964911067858338))));
    getDs().save(sevilla);

    Area newYork = new Area("New York",
        new Polygon(asList(new Position(40.75981395319104, -73.98302106186748),
            new Position(40.7636824529618, -73.98049869574606),
            new Position(40.76962974853814, -73.97964206524193),
            new Position(40.75981395319104, -73.98302106186748))));
    getDs().save(newYork);
    Area london = new Area("London",
        new Polygon(asList(new Position(51.507780365645885, -0.21786745637655258),
            new Position(51.50802478194237, -0.21474729292094707),
            new Position(51.5086863655597, -0.20895397290587425),
            new Position(51.507780365645885, -0.21786745637655258))));
    getDs().save(london);
    getDs().ensureIndexes();

    // when
    List<Position> es = asList(
        new Position(37.4056048, -5.9666089),
        new Position(37.404497, -5.9640557),
        new Position(37.407239, -5.962988),
        new Position(37.4056048, -5.9666089));
    List<Area> areaContainingPoint = getDs().find(Area.class)
                                            .filter(geoIntersects("area", new Polygon(es))).iterator().toList();

    // then
    assertThat(areaContainingPoint.size(), is(1));
    assertThat(areaContainingPoint.get(0), is(sevilla));
}
 
Example #29
Source File: GeoNearQueriesTest.java    From morphia with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldFindNearAPoint() {
    // given
    Datastore datastore = getDs();
    City london = new City("London", new Point(new Position(51.5286416, -0.1015987)));
    datastore.save(london);
    City manchester = new City("Manchester", new Point(new Position(53.4722454, -2.2235922)));
    datastore.save(manchester);
    City sevilla = new City("Sevilla", new Point(new Position(37.3753708, -5.9550582)));
    datastore.save(sevilla);

    getDs().ensureIndexes();

    final Point searchPoint = new Point(new Position(50, 0.1278));
    List<City> cities = datastore.find(City.class)
                                 .filter(near("location", searchPoint).maxDistance(200000.0)).iterator().toList();

    assertThat(cities.size(), is(1));
    assertThat(cities.get(0), is(london));

    cities = datastore.find(City.class)
                      .filter(near("location", searchPoint).maxDistance(200000D)).iterator().toList();

    assertThat(cities.size(), is(1));
    assertThat(cities.get(0), is(london));

    assertThat(datastore.find(City.class)
                        .filter(near("location", searchPoint)
                                    .maxDistance(200000D)
                                    .minDistance(195000D)).iterator().toList().size(), is(0));

    assertThat(datastore.find(City.class)
                        .filter(nearSphere("location", searchPoint)
                                    .maxDistance(200000D)
                                    .minDistance(195000D)).iterator().toList().size(), is(0));
}
 
Example #30
Source File: GeoIntersectsQueriesWithPolygonTest.java    From morphia with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldFindRoutesThatCrossAQueryPolygon() {
    // given
    Route sevilla = new Route("Spain", new LineString(asList(
        new Position(37.4056048, -5.9666089),
        new Position(37.404497, -5.9640557))));
    getDs().save(sevilla);

    Route newYork = new Route("New York", new LineString(asList(
        new Position(40.75981395319104, -73.98302106186748),
        new Position(40.7636824529618, -73.98049869574606),
        new Position(40.76962974853814, -73.97964206524193))));
    getDs().save(newYork);
    Route london = new Route("London", new LineString(asList(
        new Position(51.507780365645885, -0.21786745637655258),
        new Position(51.50802478194237, -0.21474729292094707),
        new Position(51.5086863655597, -0.20895397290587425))));
    getDs().save(london);
    Route londonToParis = new Route("London To Paris", new LineString(asList(
        new Position(51.5286416, -0.1015987),
        new Position(48.858859, 2.3470599))));
    getDs().save(londonToParis);
    getDs().ensureIndexes();

    // when
    List<Route> routeContainingPoint = getDs().find(Route.class)
                                              .filter(geoIntersects("route", new Polygon(asList(
                                                  new Position(37.40759155713022, -5.964911067858338),
                                                  new Position(37.40341208875179, -5.9643941558897495),
                                                  new Position(37.40297396667302, -5.970452763140202),
                                                  new Position(37.40759155713022, -5.964911067858338))))).iterator()
                                              .toList();

    // then
    assertThat(routeContainingPoint.size(), is(1));
    assertThat(routeContainingPoint.get(0), is(sevilla));
}