Skip to content

Commit

Permalink
fix: only delete old map layers at beginning of dataset ingest
Browse files Browse the repository at this point in the history
  • Loading branch information
annehaley committed Aug 2, 2024
1 parent 0f985c9 commit d71c90a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion sample_data/use_cases/new_york_energy/import_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.contrib.gis.measure import D
from django.contrib.gis.db.models.functions import Distance
from django.contrib.gis.geos import Point, LineString
from uvdat.core.models import Network, NetworkEdge, NetworkNode
from uvdat.core.models import Network, NetworkEdge, NetworkNode, VectorMapLayer
from uvdat.core.tasks.networks import vector_features_from_network


Expand Down Expand Up @@ -75,6 +75,7 @@ def perform_import(dataset, **kwargs):
print('\tEstimated time: 90 minutes.')
start = datetime.now()
Network.objects.filter(dataset=dataset).delete()
VectorMapLayer.objects.filter(dataset=network.dataset).delete()
for file_item in dataset.source_files.all():
with tempfile.TemporaryDirectory() as temp_dir:
archive_path = Path(temp_dir, 'archive.zip')
Expand Down
1 change: 1 addition & 0 deletions sample_data/use_cases/new_york_energy/nysdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def download_all_deduped_vector_features(**kwargs):
def create_consolidated_network(dataset, **kwargs):
start = datetime.now()
Network.objects.filter(dataset=dataset).delete()
VectorMapLayer.objects.filter(dataset=network.dataset).delete()
gdf = download_all_deduped_vector_features(**kwargs)

zones_dataset_name = kwargs.get('zones_dataset_name')
Expand Down
3 changes: 1 addition & 2 deletions uvdat/core/tasks/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy
import shapely

from uvdat.core.models import Network, NetworkEdge, NetworkNode, VectorFeature, VectorMapLayer
from uvdat.core.models import Network, NetworkEdge, NetworkNode, VectorFeature

NODE_RECOVERY_MODES = [
'random',
Expand Down Expand Up @@ -214,7 +214,6 @@ def geojson_from_network(dataset):


def vector_features_from_network(network):
VectorMapLayer.objects.filter(dataset=network.dataset).delete()
map_layer, created = VectorMapLayer.objects.get_or_create(dataset=network.dataset, index=0)
VectorFeature.objects.bulk_create(
[
Expand Down

0 comments on commit d71c90a

Please sign in to comment.