diff --git a/dhnx/gistools/connect_points.py b/dhnx/gistools/connect_points.py index 5abcc50f..3d50a3a6 100644 --- a/dhnx/gistools/connect_points.py +++ b/dhnx/gistools/connect_points.py @@ -372,11 +372,13 @@ def process_geometry(lines, consumers, producers, lines['type'] = 'DL' # DL for distribution line lines_consumers['type'] = 'HL' # HL for house line - # generate forks point layer - forks = go.create_forks(lines) - # concat lines lines_all = pd.concat([lines, lines_consumers, lines_producers], sort=False) + + forks = go.create_forks(lines_all) + + forks = go.remove_con_prod_forks(forks, consumers, producers) + lines_all.reset_index(inplace=True, drop=True) lines_all.index.name = 'id' if 'id' in lines_all.columns: diff --git a/dhnx/gistools/geometry_operations.py b/dhnx/gistools/geometry_operations.py index a8efab39..64e4f9b9 100644 --- a/dhnx/gistools/geometry_operations.py +++ b/dhnx/gistools/geometry_operations.py @@ -511,3 +511,29 @@ def check_crs(gdf, crs=4647): logging.info('CRS of GeoDataFrame converted to EPSG:{0}'.format(crs)) return gdf + + +def remove_con_prod_forks(forks, consumers, producers): + """ + + Parameters + ---------- + forks + consumers + producers + + Returns + ------- + + """ + consumers["geometry_wkt"] = \ + consumers["geometry"].apply(lambda geom: geom.wkt) + + producers["geometry_wkt"] = \ + producers["geometry"].apply(lambda geom: geom.wkt) + + con_prod = list(producers["geometry_wkt"]) + list(consumers["geometry_wkt"]) + + forks_only = forks[forks.geometry_wkt.isin(con_prod) == False] + + return forks_only