@Test public void GetCountryTest() { List<CountryBordersPolygon> containing = cbh1.getContainingPolygons(new Coordinate(0.9, 0.9)); assertEquals(1, containing.size()); assertEquals("name1", containing.get(0).getName()); containing = cbh1.getContainingPolygons(new Coordinate(0.0, 0.0)); assertEquals(2, containing.size()); containing = cbh1.getContainingPolygons(new Coordinate(10, 10)); assertEquals(0, containing.size()); }
public List<CountryBordersPolygon> getContainingPolygons(Coordinate c) { ArrayList<CountryBordersPolygon> containing = new ArrayList<>(); if(!Double.isNaN(c.x) && !Double.isNaN(c.y) && inBbox(c)) { for (CountryBordersPolygon cbp : polygons) { if (cbp.inBbox(c)) { containing.add(cbp); } } } return containing; }
CountryBordersHierarchy { public List<CountryBordersPolygon> getContainingPolygons(Coordinate c) { ArrayList<CountryBordersPolygon> containing = new ArrayList<>(); if(!Double.isNaN(c.x) && !Double.isNaN(c.y) && inBbox(c)) { for (CountryBordersPolygon cbp : polygons) { if (cbp.inBbox(c)) { containing.add(cbp); } } } return containing; } }
CountryBordersHierarchy { public List<CountryBordersPolygon> getContainingPolygons(Coordinate c) { ArrayList<CountryBordersPolygon> containing = new ArrayList<>(); if(!Double.isNaN(c.x) && !Double.isNaN(c.y) && inBbox(c)) { for (CountryBordersPolygon cbp : polygons) { if (cbp.inBbox(c)) { containing.add(cbp); } } } return containing; }  }
CountryBordersHierarchy { public List<CountryBordersPolygon> getContainingPolygons(Coordinate c) { ArrayList<CountryBordersPolygon> containing = new ArrayList<>(); if(!Double.isNaN(c.x) && !Double.isNaN(c.y) && inBbox(c)) { for (CountryBordersPolygon cbp : polygons) { if (cbp.inBbox(c)) { containing.add(cbp); } } } return containing; }  void add(CountryBordersPolygon cp); boolean inBbox(Coordinate c); double[] getBBox(); List<CountryBordersPolygon> getPolygons(); List<CountryBordersPolygon> getContainingPolygons(Coordinate c); }
CountryBordersHierarchy { public List<CountryBordersPolygon> getContainingPolygons(Coordinate c) { ArrayList<CountryBordersPolygon> containing = new ArrayList<>(); if(!Double.isNaN(c.x) && !Double.isNaN(c.y) && inBbox(c)) { for (CountryBordersPolygon cbp : polygons) { if (cbp.inBbox(c)) { containing.add(cbp); } } } return containing; }  void add(CountryBordersPolygon cp); boolean inBbox(Coordinate c); double[] getBBox(); List<CountryBordersPolygon> getPolygons(); List<CountryBordersPolygon> getContainingPolygons(Coordinate c);  }