Skip to content

Corners are not inside #1

@tspoke

Description

@tspoke

From this test, corner2 and corner3 are outside the area. If we change the longitude to 0.95 instead of 0.99 it works. The -0.05 is the same value as the increment variable in the build() function.

Looks like incrementing latitude and longitude in the TileAreaPolygonalBuilder.build() method from the center of an edge put the location outside the bbox.

testValidPolygonSquare

  //defining a large, axis-aligned area; locations within, even close to the edge,
  //should be contained
  const coords: Coordinate[] = [];
  coords.push(new Coordinate(0.0, 0.0));
  coords.push(new Coordinate(0.0, 1.0));
  coords.push(new Coordinate(1.0, 1.0));
  coords.push(new Coordinate(1.0, 0.0));

  const corner1 = OpenGeoTile.buildFromLatitudeAndLongitude(0.01, 0.01, TileSize.NEIGHBORHOOD);
  const corner2 = OpenGeoTile.buildFromLatitudeAndLongitude(0.01, 0.99, TileSize.NEIGHBORHOOD); // here 
  const corner3 = OpenGeoTile.buildFromLatitudeAndLongitude(0.99, 0.99, TileSize.NEIGHBORHOOD); // here
  const corner4 = OpenGeoTile.buildFromLatitudeAndLongitude(0.99, 0.01, TileSize.NEIGHBORHOOD);
  const center = OpenGeoTile.buildFromLatitudeAndLongitude(0.5, 0.5, TileSize.NEIGHBORHOOD);

  const testTileArea = new TileAreaPolygonalBuilder()
    .setPrecision(TileSize.DISTRICT)
    .setCoordinatesList(coords)
    .build();

  expect(testTileArea).to.not.equal(null);
  
  expect(testTileArea.contains(corner1)).to.equal(true, "Contains area near corner 1");
  expect(testTileArea.contains(corner2)).to.equal(true, "Contains area near corner 2");
  expect(testTileArea.contains(corner3)).to.equal(true, "Contains area near corner 3");
  expect(testTileArea.contains(corner4)).to.equal(true, "Contains area near corner 4");
  expect(testTileArea.contains(center)).to.equal(true, "Contains center");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions