public void op(Display display, Object target, IProgressMonitor monitor) throws Exception {
    ConfirmDialogRunnable dialog = new ConfirmDialogRunnable(display);
    display.syncExec(dialog);

    if (dialog.returnValue == Window.OK) {
      Neo4jSpatialGeoResource geoResource = (Neo4jSpatialGeoResource) target;
      Neo4jSpatialDataStore dataStore =
          (Neo4jSpatialDataStore) geoResource.service().getDataStore(monitor);

      SpatialDatabaseService spatialDatabase = dataStore.getSpatialDatabaseService();
      spatialDatabase.deleteLayer(
          geoResource.getTypeName(),
          new ProgressMonitorWrapper("Deleting Layer " + geoResource.getTypeName(), monitor));
    }
  }
Ejemplo n.º 2
0
 /**
  * Method to get the nearest parking by longitude and latitude.
  *
  * @param lon the longitude
  * @param lat the latitude
  * @param distance
  * @param status if 0 we search a station with free places and if null whatever !
  * @return
  */
 public POI getNearest(Double lon, Double lat, Double distance, Integer status)
     throws MobilITException {
   Coordinate coord = new Coordinate(lat, lon);
   EditableLayer layer = spatial.getOrCreateEditableLayer(Constant.PARKING_LAYER);
   // @formatter:off
   List<GeoPipeFlow> results =
       GeoPipeline.startNearestNeighborSearch(layer, coord, distance).sort("Distance").toList();
   // @formatter:on
   int i = 0;
   Boolean find = false;
   POI nearest = null;
   while (find == false && i < results.size()) {
     SpatialDatabaseRecord dbRecord = results.get(i).getRecord();
     Node node = dbRecord.getGeomNode();
     String geocode = (String) node.getProperty("geocode", null);
     String id = (String) node.getProperty("id", null);
     String name = (String) node.getProperty("name", null);
     Double lng = (Double) node.getProperty("lon", null);
     Double lati = (Double) node.getProperty("lat", null);
     if (status != null) {
       AbstractParking service = this.getGeoService(geocode);
       HashMap<String, Integer> places = (HashMap<String, Integer>) service.getParking(id);
       if (places.isEmpty()) {
         // here there is no information
         nearest = new POI(id, name, lng, lati, geocode);
         find = true;
       } else {
         Integer free = places.get(Constant.PARKING_FREE);
         if (free != null && free > 0) {
           nearest = new POI(id, name, lng, lati, geocode);
           find = true;
         }
       }
     } else {
       nearest = new POI(id, name, lng, lati, geocode);
       find = true;
     }
     i++;
   }
   // TODO: throw an exception if there is no station ?
   return nearest;
 }
Ejemplo n.º 3
0
 public LayerNodeIndex(String indexName, GraphDatabaseService db, Map<String, String> config) {
   this.layerName = indexName;
   this.db = db;
   spatialDB = new SpatialDatabaseService(this.db);
   layer = (EditableLayer) spatialDB.getOrCreateEditableLayer(layerName);
 }