Skip to content

Commit

Permalink
fix tasks duplicated tables (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap authored Dec 16, 2024
1 parent 1033f39 commit 980e21c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
23 changes: 13 additions & 10 deletions backend/app/worker/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
i3dm_db = f"Host={settings.POSTGRES_SERVER};Username={settings.POSTGRES_USER};password={settings.POSTGRES_PASSWORD};Port={settings.POSTGRES_PORT};Database={settings.POSTGRES_TASKS_DB}"

def earcut_js(coordinates):
coordinates_str = json.dumps(coordinates)
result = subprocess.run([
'node',
'/app/node/earcut.js',
coordinates_str
], stdout=subprocess.PIPE)
output = list(map(int, result.stdout.decode("utf-8").split(',')))
return output
try:
coordinates_str = json.dumps(coordinates)
result = subprocess.run([
'node',
'/app/node/earcut.js',
coordinates_str
], stdout=subprocess.PIPE)
output = list(map(int, result.stdout.decode("utf-8").split(',')))
return output
except Exception:
return []

def identify_projection(projection):
try:
Expand Down Expand Up @@ -134,8 +137,8 @@ def pg2b3dm(table_task_name, output_3dtiles_path, attributes, min_geometric_erro
'--use_implicit_tiling', "false",
'--max_features_per_tile', f"{int(max_features_per_tile)}"
],
capture_output = True,
text = True
# capture_output = True,
# text = True
)

try:
Expand Down
14 changes: 5 additions & 9 deletions backend/app/worker/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ def setup_output_directory(pipeline_id):
def create_point_instance_3dtiles(pipeline_extended):

asset = pipeline_extended['asset']
asset_upload_path = get_asset_upload_path(asset['id'], asset['extension'])
asset_id = asset['id']
pipeline_id = pipeline_extended['id']
table_name = get_asset_table_name(asset_id)
Expand All @@ -188,8 +187,6 @@ def create_point_instance_3dtiles(pipeline_extended):
**pipeline_config
}

import_vector_to_postgres(asset_upload_path, table_name, geometry_column_name, fid_column_name)

table = Table(table_name, MetaData(), autoload_with=engine_tasks)

table_task_name = get_pipeline_table_name(pipeline_id)
Expand Down Expand Up @@ -303,7 +300,6 @@ def create_point_instance_3dtiles(pipeline_extended):
def create_mesh_3dtiles(pipeline_extended):

asset = pipeline_extended['asset']
asset_upload_path = get_asset_upload_path(asset['id'], asset['extension'])
asset_id = asset['id']
pipeline_id = pipeline_extended['id']
table_name = get_asset_table_name(asset_id)
Expand All @@ -330,8 +326,6 @@ def create_mesh_3dtiles(pipeline_extended):
**pipeline_config
}

import_vector_to_postgres(asset_upload_path, table_name, geometry_column_name, fid_column_name)

table = Table(table_name, MetaData(), autoload_with=engine_tasks)

table_task_name = get_pipeline_table_name(pipeline_id)
Expand Down Expand Up @@ -393,9 +387,11 @@ def create_mesh_3dtiles(pipeline_extended):
}

polyhedron_wkt = polyhedral_to_wkt(geometry_to_polyhedral_surface(geometry, geometry_options))

feature_properties[geometry_column_name] = polyhedron_wkt
session.exec(insert(table_tasks).values(feature_properties))
if polyhedron_wkt != 'POLYHEDRALSURFACE Z()':
feature_properties[geometry_column_name] = polyhedron_wkt
session.exec(insert(table_tasks).values(feature_properties))
else:
print(f'Error creating polyhedron:', feature)

session.commit()

Expand Down
Empty file modified backend/scripts/celery-reload.sh
100644 → 100755
Empty file.
Empty file modified backend/scripts/celery.sh
100644 → 100755
Empty file.

0 comments on commit 980e21c

Please sign in to comment.