コード例 #1
0
  @SuppressWarnings("unchecked")
  public JerPlace getAdditionalInstancesForSpecificPlace(final int selectedID2)
      throws ParseException {
    final GeometryFactory gf = new GeometryFactory();
    final JerGeoObserverMsg geoMsg = new JerGeoObserverMsg();
    final List<Object> pathObjLi =
        readDB(selectedModel.getSqlAdditionalInstancesForSpecificPlace(selectedID2));

    for (final Object o : pathObjLi) {
      final List<Object> objLi = (List<Object>) o;

      if (objLi.size() == 2 && objLi.get(0) != null && objLi.get(1) != null) {
        final Point p =
            gf.createPoint(new Coordinate((double) objLi.get(0), (double) objLi.get(1)));
        final JerPlace place = new JerPlace(p);
        geoMsg.addPlaceToLi(place);
      }

      if (objLi.size() == 3 && objLi.get(0) != null && objLi.get(1) != null) {
        final Point p =
            gf.createPoint(new Coordinate((double) objLi.get(0), (double) objLi.get(1)));
        final JerPlace place = new JerPlace(p);
        if (objLi.get(2) != null) {
          final WKTReader wktr = new WKTReader(gf);
          final Geometry additional = wktr.read((String) objLi.get(2));
          place.setAdditionalInstances(additional);
        }
        geoMsg.addPlaceToLi(place);
      }

      if (objLi.size() == 4 && objLi.get(1) != null && objLi.get(2) != null) {
        final Point p =
            gf.createPoint(new Coordinate((double) objLi.get(1), (double) objLi.get(2)));
        final JerPlace place = new JerPlace(p);
        if (objLi.get(0) != null) {
          place.setNumber((int) objLi.get(0));
        }
        if (objLi.get(3) != null) {
          final WKTReader wktr = new WKTReader(gf);
          final Geometry additional = wktr.read((String) objLi.get(3));
          place.setAdditionalInstances(additional);
        }
        geoMsg.addPlaceToLi(place);
      }
    }
    return geoMsg.getPlaceLi().get(0);
  }
コード例 #2
0
  @SuppressWarnings("unchecked")
  public void checkAssociatedPlaces(
      final JerModel jerModel, final String modelIDName, final int val) throws ParseException {

    // default show all places
    String sql = JerModel.sqlAllPlacesAndInformation;

    if (val != -1) {
      if (modelIDName.equalsIgnoreCase("AUTHOR_ID")) {
        sql =
            "SELECT LOCATION_EASTING, LOCATION_NORTHING, SIMPLE_FEATURE FROM (SELECT LOCATION_EASTING, LOCATION_NORTHING, SIMPLE_FEATURE,  PLACE_ID FROM JERUSALEM.PLACES)TAB5 INNER JOIN (SELECT PLACE_ID FROM (SELECT PLACE_ID, ENTRY_ID FROM JERUSALEM.TOPOS_IN_ENTRY)TAB3 INNER JOIN (SELECT ENTRY_ID FROM(SELECT ENTRY_ID, DOCUMENT_ID FROM JERUSALEM.ENTRIES)TAB1 INNER JOIN (SELECT DOCUMENT_ID FROM JERUSALEM.DOCUMENTS WHERE AUTHOR_ID = "
                + val
                + ")TAB2 ON TAB1.DOCUMENT_ID = TAB2.DOCUMENT_ID)TAB4 ON TAB3.ENTRY_ID=TAB4.ENTRY_ID)TAB6 ON TAB5.PLACE_ID=TAB6.PLACE_ID";
      }
      if (modelIDName.equalsIgnoreCase("DOCUMENT_ID")) {
        sql =
            "SELECT NUMBER, LOCATION_EASTING, LOCATION_NORTHING, SIMPLE_FEATURE FROM (SELECT LOCATION_EASTING, LOCATION_NORTHING, SIMPLE_FEATURE, PLACE_ID FROM JERUSALEM.PLACES)TAB3 INNER JOIN (SELECT PLACE_ID, NUMBER FROM (SELECT PLACE_ID, ENTRY_ID, NUMBER FROM JERUSALEM.TOPOS_IN_ENTRY)TAB1 INNER JOIN (SELECT ENTRY_ID FROM JERUSALEM.ENTRIES WHERE DOCUMENT_ID = "
                + val
                + ")TAB2 ON TAB1.ENTRY_ID = TAB2.ENTRY_ID)TAB4 ON TAB3.PLACE_ID=TAB4.PLACE_ID ORDER BY NUMBER";
      }
      if (modelIDName.equalsIgnoreCase("ENTRY_ID")) {
        sql =
            "SELECT LOCATION_EASTING, LOCATION_NORTHING, SIMPLE_FEATURE FROM (SELECT PLACE_ID FROM JERUSALEM.TOPOS_IN_ENTRY WHERE ENTRY_ID = "
                + val
                + ")TAB1 INNER JOIN (SELECT PLACE_ID, LOCATION_EASTING, LOCATION_NORTHING,  SIMPLE_FEATURE FROM JERUSALEM.PLACES)TAB2 ON TAB1.PLACE_ID=TAB2.PLACE_ID";
      }
      if (modelIDName.equalsIgnoreCase("PLACE_ID")) {
        sql =
            "SELECT LOCATION_EASTING, LOCATION_NORTHING, SIMPLE_FEATURE FROM JERUSALEM.PLACES WHERE PLACE_ID = "
                + val;
      }
      if (modelIDName.equalsIgnoreCase("TOPOS_ID")) {
        sql =
            "SELECT LOCATION_EASTING, LOCATION_NORTHING, SIMPLE_FEATURE FROM(SELECT LOCATION_EASTING, LOCATION_NORTHING, SIMPLE_FEATURE, PLACE_ID FROM JERUSALEM.PLACES)TAB1 INNER JOIN (SELECT PLACE_ID FROM JERUSALEM.PLACETOPOS WHERE TOPOS_ID = "
                + val
                + ")TAB2 ON TAB1.PLACE_ID=TAB2.PLACE_ID";
      }
      if (modelIDName.equalsIgnoreCase("TOPOS_IN_ENTRY_ID")) {
        sql =
            "SELECT  LOCATION_EASTING, LOCATION_NORTHING, SIMPLE_FEATURE FROM (SELECT PLACE_ID FROM JERUSALEM.TOPOS_IN_ENTRY WHERE TOPOS_IN_ENTRY_ID = "
                + val
                + ")TAB1 INNER JOIN (SELECT PLACE_ID, LOCATION_EASTING, LOCATION_NORTHING,  SIMPLE_FEATURE FROM JERUSALEM.PLACES)TAB2 ON TAB1.PLACE_ID=TAB2.PLACE_ID";
      }
    }

    final List<Object> pathObjLi = readDB(sql);
    final JerGeoObserverMsg geoMsg = new JerGeoObserverMsg();
    final GeometryFactory gf = new GeometryFactory();

    for (final Object o : pathObjLi) {
      final List<Object> objLi = (List<Object>) o;

      if (objLi.size() == 2 && objLi.get(0) != null && objLi.get(1) != null) {
        final Point p =
            gf.createPoint(new Coordinate((double) objLi.get(0), (double) objLi.get(1)));
        final JerPlace place = new JerPlace(p);
        geoMsg.addPlaceToLi(place);
      }

      if (modelIDName.equalsIgnoreCase("DOCUMENT_ID")
          && val != -1
          && objLi.size() == 3
          && objLi.get(1) != null
          && objLi.get(2) != null) {
        final Point p =
            gf.createPoint(new Coordinate((double) objLi.get(1), (double) objLi.get(2)));
        final JerPlace place = new JerPlace(p);
        if (objLi.get(0) != null) {
          place.setNumber((int) objLi.get(0));
        }
        geoMsg.addPlaceToLi(place);
      }

      if (objLi.size() == 3 && objLi.get(0) != null && objLi.get(1) != null) {
        final Point p =
            gf.createPoint(new Coordinate((double) objLi.get(0), (double) objLi.get(1)));
        final JerPlace place = new JerPlace(p);
        if (objLi.get(2) != null) {
          final WKTReader wktr = new WKTReader(gf);
          final Geometry additional = wktr.read((String) objLi.get(2));
          place.setAdditionalInstances(additional);
        }
        geoMsg.addPlaceToLi(place);
      }

      if (objLi.size() == 4 && objLi.get(1) != null && objLi.get(2) != null) {
        final Point p =
            gf.createPoint(new Coordinate((double) objLi.get(1), (double) objLi.get(2)));
        final JerPlace place = new JerPlace(p);
        if (objLi.get(0) != null) {
          place.setNumber((int) objLi.get(0));
        }
        if (objLi.get(3) != null) {
          final WKTReader wktr = new WKTReader(gf);
          final Geometry additional = wktr.read((String) objLi.get(3));
          place.setAdditionalInstances(additional);
        }
        geoMsg.addPlaceToLi(place);
      }
    }
    informAboutCoordinates(geoMsg);
  }