Exemplo n.º 1
0
 public function deleteBulk($property_id, $type)
 {
     $geo_properties = \GeoProperty::where('source_id', '=', $property_id)->where('source_type', '=', $type, 'AND')->get();
     foreach ($geo_properties as $geo_property) {
         $geo_property->delete();
     }
 }
Exemplo n.º 2
0
 /**
  * Delete everything out of our testing database.
  */
 public static function tearDownAfterClass()
 {
     parent::tearDownAfterClass();
     \Definition::truncate();
     \CsvDefinition::truncate();
     \InstalledDefinition::truncate();
     \JsonDefinition::truncate();
     \ShpDefinition::truncate();
     \SparqlDefinition::truncate();
     \XlsDefinition::truncate();
     \XmlDefinition::truncate();
     \GeoProperty::truncate();
     \TabularColumns::truncate();
     \Geoprojection::truncate();
 }
Exemplo n.º 3
0
 /**
  * Seed the SHP definitions
  */
 private function seedShp()
 {
     $shp_data = array('rivers' => array('file' => 'gis.osm_boundaries_v06', 'collection' => 'dresden', 'name' => 'rivers', 'description' => 'Shape file about rivers in Dresden.', 'columns' => array(array('column_name' => 'osm_id', 'index' => 0, 'column_name_alias' => 'osm_id', 'is_pk' => 0), array('column_name' => 'lastchange', 'index' => 1, 'column_name_alias' => 'lastchange', 'is_pk' => 0), array('column_name' => 'code', 'index' => 2, 'column_name_alias' => 'code', 'is_pk' => 0), array('column_name' => 'fclass', 'index' => 3, 'column_name_alias' => 'fclass', 'is_pk' => 0), array('column_name' => 'deleted', 'index' => 4, 'column_name_alias' => 'deleted', 'is_pk' => 0), array('column_name' => 'parts', 'index' => 5, 'column_name_alias' => 'parts', 'is_pk' => 0)), 'geo' => array(array('path' => 'parts', 'property' => 'polyline'))), 'places' => array('file' => 'places', 'name' => 'places', 'collection' => 'france', 'description' => 'Interesting places from "Ile-de-France".', 'columns' => array(array('column_name' => 'osm_id', 'index' => 0, 'column_name_alias' => 'osm_id', 'is_pk' => 0), array('column_name' => 'name', 'index' => 1, 'column_name_alias' => 'name', 'is_pk' => 0), array('column_name' => 'type', 'index' => 2, 'column_name_alias' => 'type', 'is_pk' => 0), array('column_name' => 'population', 'index' => 3, 'column_name_alias' => 'population', 'is_pk' => 0), array('column_name' => 'deleted', 'index' => 4, 'column_name_alias' => 'deleted', 'is_pk' => 0), array('column_name' => 'x', 'index' => 5, 'column_name_alias' => 'x', 'is_pk' => 0), array('column_name' => 'y', 'index' => 6, 'column_name_alias' => 'y', 'is_pk' => 0)), 'geo' => array(array('path' => 'x', 'property' => 'latitude'), array('path' => 'y', 'property' => 'longitude'))));
     $added = false;
     foreach ($shp_data as $directory => $info) {
         // Don't create doubles
         $definition = Definition::where('collection_uri', '=', $info['collection'])->where('resource_name', '=', $info['name'])->first();
         if (empty($definition)) {
             // Create a new ShpDefinition
             $shp_def = new ShpDefinition();
             $shp_def->uri = app_path() . '/storage/data/shp/' . $directory . '/' . $info['file'] . '.shp';
             $shp_def->description = $info['description'];
             $shp_def->epsg = 4326;
             $shp_def->save();
             // Add the tabular columns
             foreach ($info['columns'] as $column) {
                 $tab_column = new TabularColumns();
                 $tab_column->column_name = $column['column_name'];
                 $tab_column->index = $column['index'];
                 $tab_column->column_name_alias = $column['column_name_alias'];
                 $tab_column->is_pk = $column['is_pk'];
                 $tab_column->tabular_id = $shp_def->id;
                 $tab_column->tabular_type = 'ShpDefinition';
                 $tab_column->save();
             }
             // Add the geo properties
             foreach ($info['geo'] as $geo) {
                 $geo_prop = new GeoProperty();
                 $geo_prop->source_type = 'ShpDefinition';
                 $geo_prop->source_id = $shp_def->id;
                 $geo_prop->property = $geo['property'];
                 $geo_prop->path = $geo['path'];
                 $geo_prop->save();
             }
             // Add the ShpDefinition to the Definition
             $definition = new Definition();
             $definition->collection_uri = $info['collection'];
             $definition->resource_name = $info['name'];
             $definition->source_id = $shp_def->id;
             $definition->source_type = 'ShpDefinition';
             $definition->draft = false;
             $definition->save();
             $this->command->info("Published a SHP file.");
             $added = true;
         }
     }
     if (!$added) {
         $this->command->info("No SHP files have been published, all of the uri's that the SHP seeder wanted to use are already taken.");
     }
 }