public static String findTerritoryName(final Point p,final Map<String,List<Polygon>> terrPolygons,final String defaultTerrName){
  String lastWaterTerrName=defaultTerrName;
  for (  final String terrName : terrPolygons.keySet()) {
    final Collection<Polygon> polygons=terrPolygons.get(terrName);
    for (    final Polygon poly : polygons) {
      if (poly.contains(p)) {
        if (Util.isTerritoryNameIndicatingWater(terrName)) {
          lastWaterTerrName=terrName;
        }
 else {
          return terrName;
        }
      }
    }
  }
  return lastWaterTerrName;
}

public static String findTerritoryName ( final Point p , final Map < String , List < Polygon > > terrPolygons , final String defaultTerrName ) { String lastWaterTerrName = defaultTerrName ; for ( final String terrName : terrPolygons . keySet ( ) ) { final Collection < Polygon > polygons = terrPolygons . get ( terrName ) ; for ( final Polygon poly : polygons ) { if ( poly . contains ( p ) ) { if ( Util . isTerritoryNameIndicatingWater ( terrName ) ) { lastWaterTerrName = terrName ; } else { return terrName ; } } } } return lastWaterTerrName ; }
java . lang . string findterritoryname ( java . awt . point ) finds a land territory name or some sea zone name where the point is contained in according to the territory name - > polygons map . if no land or sea territory has been found a default name is returned .
