r2gg 2.2.2__tar.gz → 2.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {r2gg-2.2.2 → r2gg-2.2.4}/PKG-INFO +1 -1
  2. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg/__about__.py +1 -1
  3. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg/_pivot_to_osm.py +66 -37
  4. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg/_pivot_to_pgr.py +32 -2
  5. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg.egg-info/PKG-INFO +1 -1
  6. {r2gg-2.2.2 → r2gg-2.2.4}/LICENSE +0 -0
  7. {r2gg-2.2.2 → r2gg-2.2.4}/README.md +0 -0
  8. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg/__init__.py +0 -0
  9. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg/_configure.py +0 -0
  10. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg/_file_copier.py +0 -0
  11. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg/_lua_builder.py +0 -0
  12. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg/_main.py +0 -0
  13. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg/_osm_building.py +0 -0
  14. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg/_osm_to_pbf.py +0 -0
  15. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg/_output_costs_from_costs_config.py +0 -0
  16. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg/_path_converter.py +0 -0
  17. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg/_read_config.py +0 -0
  18. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg/_sql_building.py +0 -0
  19. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg/_subprocess_execution.py +0 -0
  20. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg/_valhalla_lua_builder.py +0 -0
  21. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg/cli.py +0 -0
  22. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg.egg-info/SOURCES.txt +0 -0
  23. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg.egg-info/dependency_links.txt +0 -0
  24. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg.egg-info/entry_points.txt +0 -0
  25. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg.egg-info/requires.txt +0 -0
  26. {r2gg-2.2.2 → r2gg-2.2.4}/r2gg.egg-info/top_level.txt +0 -0
  27. {r2gg-2.2.2 → r2gg-2.2.4}/setup.cfg +0 -0
  28. {r2gg-2.2.2 → r2gg-2.2.4}/setup.py +0 -0
  29. {r2gg-2.2.2 → r2gg-2.2.4}/tests/test_cli.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: r2gg
3
- Version: 2.2.2
3
+ Version: 2.2.4
4
4
  Summary: Route Graph Generator (r2gg) est un script Python qui permet la génération de graphes pour des moteurs de calcul d'itinéraire
5
5
  Home-page: https://github.com/IGNF/route-graph-generator/
6
6
  Author: IGNF
@@ -34,7 +34,7 @@ __uri_repository__ = "https://github.com/IGNF/route-graph-generator/"
34
34
  __uri_tracker__ = f"{__uri_repository__}issues/"
35
35
  __uri__ = __uri_repository__
36
36
 
37
- __version__ = "2.2.2"
37
+ __version__ = "2.2.4"
38
38
  __version_info__ = tuple(
39
39
  [
40
40
  int(num) if num.isdigit() else num
@@ -69,54 +69,83 @@ def pivot_to_osm(config, source, db_configs, connection, logger, output_is_pbf =
69
69
  attribs = {"version": "0.6", "generator": "r2gg"}
70
70
  with xf.element("osm", attribs):
71
71
 
72
- # Ecriture des nodes
73
- sql_query = getQueryByTableAndBoundingBox(f'{input_schema}.nodes', source['bbox'])
72
+ # Récupération du nombre de nodes
73
+ sql_query = f"SELECT COUNT(*) as cnt FROM {input_schema}.nodes"
74
74
  logger.info("SQL: {}".format(sql_query))
75
75
  st_execute = time.time()
76
76
  cursor.execute(sql_query)
77
77
  et_execute = time.time()
78
78
  logger.info("Execution ended. Elapsed time : %s seconds." %(et_execute - st_execute))
79
79
  row = cursor.fetchone()
80
- logger.info("Writing nodes")
81
- st_execute = time.time()
82
- i = 1
83
- while row:
84
- nodeEl = writeNode(row, extraction_date)
85
- xf.write(nodeEl, pretty_print=True)
86
- row = cursor.fetchone()
87
- if (i % ceil(cursor.rowcount/10) == 0):
88
- logger.info("%s / %s nodes ajoutés" %(i, cursor.rowcount))
89
- i += 1
90
- et_execute = time.time()
91
- logger.info("Writing nodes ended. Elapsed time : %s seconds." %(et_execute - st_execute))
80
+ nodesize = row["cnt"]
92
81
 
93
- # Ecriture des ways
94
- sql_query2 = getQueryByTableAndBoundingBox(f'{input_schema}.edges', source['bbox'], ['*', f'{input_schema}.inter_nodes(geom) as internodes'])
95
- logger.info("SQL: {}".format(sql_query2))
82
+ # Ecriture des nodes
83
+ batchsize = 500000
84
+ offset = 0
85
+ logger.info(f"Writing nodes: {nodesize} ways to write")
86
+ st_nodes = time.time()
87
+ while offset < nodesize:
88
+ sql_query = getQueryByTableAndBoundingBox(f'{input_schema}.nodes', source['bbox'])
89
+ sql_query += " LIMIT {} OFFSET {}".format(batchsize, offset)
90
+ logger.info("SQL: {}".format(sql_query))
91
+ st_execute = time.time()
92
+ cursor.execute(sql_query)
93
+ et_execute = time.time()
94
+ offset += batchsize
95
+ logger.info("Execution ended. Elapsed time : %s seconds." %(et_execute - st_execute))
96
+ row = cursor.fetchone()
97
+ logger.info("Writing nodes")
98
+ st_execute = time.time()
99
+ i = 1
100
+ while row:
101
+ nodeEl = writeNode(row, extraction_date)
102
+ xf.write(nodeEl, pretty_print=True)
103
+ row = cursor.fetchone()
104
+ logger.info("%s / %s nodes ajoutés" %(offset, nodesize))
105
+ et_nodes = time.time()
106
+ logger.info("Writing nodes ended. Elapsed time : %s seconds." %(et_nodes - st_nodes))
107
+
108
+ # Récupération du nombre de ways
109
+ sql_query = f"SELECT COUNT(*) as cnt FROM {input_schema}.edges"
110
+ logger.info("SQL: {}".format(sql_query))
96
111
  st_execute = time.time()
97
- cursor.execute(sql_query2)
112
+ cursor.execute(sql_query)
98
113
  et_execute = time.time()
99
114
  logger.info("Execution ended. Elapsed time : %s seconds." %(et_execute - st_execute))
100
115
  row = cursor.fetchone()
101
- logger.info("Writing ways")
102
- st_execute = time.time()
103
- i = 1
104
- while row:
105
- wayEl = writeWay(row, extraction_date)
106
- for node in row['internodes']:
107
- vertexSequence = vertexSequence + 1
108
- node['id'] = vertexSequence
109
- nodeEl = writeNode(node, extraction_date)
110
- xf.write(nodeEl, pretty_print=True)
111
- wayEl = writeWayNds(wayEl, row, row['internodes'])
112
- wayEl = writeWayTags(wayEl, row)
113
- xf.write(wayEl, pretty_print=True)
114
- row = cursor.fetchone()
115
- if (i % ceil(cursor.rowcount/10) == 0):
116
- logger.info("%s / %s ways ajoutés" %(i, cursor.rowcount))
117
- i += 1
118
- et_execute = time.time()
119
- logger.info("Writing ways ended. Elapsed time : %s seconds." %(et_execute - st_execute))
116
+ edgesize = row["cnt"]
117
+
118
+ # Ecriture des ways
119
+ batchsize = 300000
120
+ offset = 0
121
+ logger.info(f"Writing ways: {edgesize} ways to write")
122
+ st_edges = time.time()
123
+ while offset < edgesize:
124
+ sql_query2 = getQueryByTableAndBoundingBox(f'{input_schema}.edges', source['bbox'], ['*', f'{input_schema}.inter_nodes(geom) as internodes'])
125
+ sql_query2 += " LIMIT {} OFFSET {}".format(batchsize, offset)
126
+ logger.info("SQL: {}".format(sql_query2))
127
+ st_execute = time.time()
128
+ cursor.execute(sql_query2)
129
+ et_execute = time.time()
130
+ offset += batchsize
131
+ logger.info("Execution ended. Elapsed time : %s seconds." %(et_execute - st_execute))
132
+ row = cursor.fetchone()
133
+ st_execute = time.time()
134
+ i = 1
135
+ while row:
136
+ wayEl = writeWay(row, extraction_date)
137
+ for node in row['internodes']:
138
+ vertexSequence = vertexSequence + 1
139
+ node['id'] = vertexSequence
140
+ nodeEl = writeNode(node, extraction_date)
141
+ xf.write(nodeEl, pretty_print=True)
142
+ wayEl = writeWayNds(wayEl, row, row['internodes'])
143
+ wayEl = writeWayTags(wayEl, row)
144
+ xf.write(wayEl, pretty_print=True)
145
+ row = cursor.fetchone()
146
+ logger.info("%s / %s ways ajoutés" %(offset, edgesize))
147
+ et_edges = time.time()
148
+ logger.info("Writing ways ended. Elapsed time : %s seconds." %(et_edges - st_edges))
120
149
 
121
150
  # Ecriture des restrictions
122
151
  sql_query3 = f"select * from {input_schema}.non_comm"
@@ -395,13 +395,43 @@ def pivot_to_pgr(source, cost_calculation_file_path, connection_work, connection
395
395
 
396
396
  for profile_name in profile_names:
397
397
  logger.info("Cleaning isolated edges for profile {}...".format(profile_name))
398
- clean_graph_query = "SELECT {0}.clean_graph('{1}')".format(schema, profile_name)
398
+ clean_graph_query = """
399
+ WITH connected_components AS (
400
+ SELECT * FROM pgr_connectedComponents(
401
+ 'SELECT id, source, target, cost_s_{1} as cost, reverse_cost_s_{1} as reverse_cost FROM {0}.ways'
402
+ )
403
+ ),
404
+ remove_nodes AS (
405
+ SELECT node
406
+ FROM
407
+ connected_components
408
+ WHERE
409
+ component = ANY(
410
+ SELECT DISTINCT component
411
+ FROM
412
+ (
413
+ SELECT component, count(*) AS nb
414
+ FROM
415
+ connected_components
416
+ GROUP BY component
417
+ )
418
+ AS components
419
+ WHERE nb <= 10
420
+ )
421
+ )
422
+ UPDATE {0}.ways
423
+ SET cost_s_{1} = -1,
424
+ reverse_cost_s_{1} = -1,
425
+ cost_m_{1} = -1,
426
+ reverse_cost_m_{1} = -1
427
+ WHERE {0}.ways.target = ANY(SELECT * from remove_nodes) OR {0}.ways.source = ANY(SELECT * from remove_nodes);
428
+ """.format(schema, profile_name)
399
429
  logger.info("SQL: {}".format(clean_graph_query))
400
430
  cursor_isolated.execute(clean_graph_query)
431
+ connection_out.commit()
401
432
 
402
433
  et_execute = time.time()
403
434
  logger.info("Execution ended. Elapsed time : %s seconds." %(et_execute - st_execute))
404
- connection_out.commit()
405
435
  cursor_isolated.close()
406
436
 
407
437
  end_time = time.time()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: r2gg
3
- Version: 2.2.2
3
+ Version: 2.2.4
4
4
  Summary: Route Graph Generator (r2gg) est un script Python qui permet la génération de graphes pour des moteurs de calcul d'itinéraire
5
5
  Home-page: https://github.com/IGNF/route-graph-generator/
6
6
  Author: IGNF
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes