Skip to content

Commit

Permalink
Merge pull request #112 from OnroerendErfgoed/release/0.4.0
Browse files Browse the repository at this point in the history
Release/0.4.0
  • Loading branch information
dieuska authored Oct 3, 2024
2 parents 0c588f4 + 41a2281 commit b799fb6
Show file tree
Hide file tree
Showing 39 changed files with 1,527 additions and 1,278 deletions.
17 changes: 17 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,24 @@
- Bugfixing:
- adding a safe_equals-function to catch GEOsException bug [#71]

# 0.4.0

! Not Backwards compatable !

- Refactoring:
- Possibility for parallel processing [#97]
- Changed Aligner constants to init-settings [#83]
- Refactored ID-handling so strings,integers,... can be used as ID[#110]
- Cleaned examples [#100]

- Functionalities:
- Added evaluation-attributes to evaluate()-function [#99]
- processing-remarks available in geojson-output [#103]
- Added warning when input/output changed from polygon/multipolygon [#107]

- Bugfixing:
- Bugfix on version_date [#96]
- Bugfix on disappearing features [#105]



Expand Down
2 changes: 1 addition & 1 deletion brdr/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.0"
__version__ = "0.4.0"
945 changes: 636 additions & 309 deletions brdr/aligner.py

Large diffs are not rendered by default.

61 changes: 19 additions & 42 deletions brdr/constants.py
Original file line number Diff line number Diff line change
@@ -1,68 +1,45 @@
# Thresholds
# Area in m² for excluding candidate reference when overlap(m²) is smaller than the
# threshold
THRESHOLD_EXCLUSION_AREA = 0
# Percentage for excluding candidate reference when overlap(%) is smaller than the
# threshold
THRESHOLD_EXCLUSION_PERCENTAGE = 0

# Buffer parameters:
# Explanation and examples:
# https://shapely.readthedocs.io/en/stable/reference/shapely.buffer.html
# https://postgis.net/docs/ST_Buffer.html
# Distance to limit a buffered corner (MITER-join-style parameter)
MITRE_LIMIT = 10
# Used in buffer-operations to define a quarter circle
QUAD_SEGMENTS = 5

# Correction-parameters (technical)

# Multiplication-factor used in OD-strategy 2 (SNAP-BOTH SIDED) when calculating
# OD-area to take into account
BUFFER_MULTIPLICATION_FACTOR = 1.01
# Threshold-value to exclude circles getting processed (perfect circle = 1) based on
# POLSPY-POPPER algorithm
THRESHOLD_CIRCLE_RATIO = 0.98
# Distance used in a pos_neg_buffer to remove slivers (technical correction)
CORR_DISTANCE = 0.01

# Download-settings: when extracting features by URL
# max buffer around thematic geometry to download reference parcels
MAX_REFERENCE_BUFFER = 10
# Limit used when extracting features by URL, using the feature API (f.e. from GRB)
DOWNLOAD_LIMIT = 10000

# default CRS:
DEFAULT_CRS = "EPSG:31370" # BelgianLambert72

# MULTI_SINGLE_ID_SEPARATOR #separator to split multipolygon_ids to single polygons
MULTI_SINGLE_ID_SEPARATOR = "*$*"


FORMULA_FIELD_NAME = "brdr_formula"
EVALUATION_FIELD_NAME = "brdr_evaluation"
NR_CALCULATION_FIELD_NAME = "brdr_nr_calculations"
RELEVANT_DISTANCE_FIELD_NAME = "brdr_relevant_distance"
PREFIX_FIELDNAME = "brdr_"
BASE_FORMULA_FIELD_NAME = (
PREFIX_FIELDNAME + "base_formula"
) # for use in grb_actualisation
FORMULA_FIELD_NAME = PREFIX_FIELDNAME + "formula"
EVALUATION_FIELD_NAME = PREFIX_FIELDNAME + "evaluation"
DIFF_PERCENTAGE_FIELD_NAME = PREFIX_FIELDNAME + "diff_percentage"
DIFF_AREA_FIELD_NAME = PREFIX_FIELDNAME + "diff_area"
FULL_BASE_FIELD_NAME = PREFIX_FIELDNAME + "full_base"
FULL_ACTUAL_FIELD_NAME = PREFIX_FIELDNAME + "full_actual"
EQUAL_REFERENCE_FEATURES_FIELD_NAME = PREFIX_FIELDNAME + "equal_reference_features"
OD_ALIKE_FIELD_NAME = PREFIX_FIELDNAME + "od_alike"

NR_CALCULATION_FIELD_NAME = PREFIX_FIELDNAME + "nr_calculations"
RELEVANT_DISTANCE_FIELD_NAME = PREFIX_FIELDNAME + "relevant_distance"
REMARK_FIELD_NAME = PREFIX_FIELDNAME + "remark"
LAST_VERSION_DATE = "last_version_date"
VERSION_DATE = "version_date"

DATE_FORMAT = "%Y-%m-%d"

# GRB_CONSTANTS
# max buffer (m) around thematic geometry to download reference parcels
GRB_MAX_REFERENCE_BUFFER = 10
# URL of the OGC feature API of actual GRB to extract collections
GRB_FEATURE_URL = "https://geo.api.vlaanderen.be/GRB/ogc/features/collections"

# URL of the OGC feature API of GRB fiscal parcels (situation of 1st of January) to
# extract collections
GRB_FISCAL_PARCELS_URL = "https://geo.api.vlaanderen.be/Adpf/ogc/features/collections"

# Property-name of version_date
GRB_VERSION_DATE = "VERSDATUM"

# Property-name of id of GRB-parcels
GRB_PARCEL_ID = "CAPAKEY"

# Property-name of id of GRB-parcels
GRB_BUILDING_ID = "OIDN"

# Property-name of id of GRB-parcels
GRB_KNW_ID = "OIDN"
19 changes: 10 additions & 9 deletions brdr/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class AlignerResultType(str, Enum):
"""

PREDICTIONS = "predictions"
EVALUATED_PREDICTIONS = "evaluated_predictions"
PROCESSRESULTS = "processresults"


Expand Down Expand Up @@ -95,17 +96,17 @@ class Evaluation(str, Enum):
"""
Enum to evaluate an automatically updated geometry:
* EQUALITY_FORMULA_GEOM_1 = "equality_formula_geom_1"
* EQUALITY_FORMULA_2 = "equality_formula_2"
* EQUALITY_GEOM_3 = "equality_geom_3"
* TO_CHECK_4 = "to_check_4"
* NO_PREDICTION_5 = "no_prediction_5"
* NO_CHANGE_6 = "no_change_6"
EQUALITY_EQUAL_FORMULA_FULL_1 = "equality_equal_formula_full_1"
EQUALITY_EQUAL_FORMULA_2 = "equality_equal_formula_2"
EQUALITY_FULL_3 = "equality_full_3"
TO_CHECK_4 = "to_check_4"
NO_PREDICTION_5 = "no_prediction_5"
NO_CHANGE_6 = "no_change_6"
"""

EQUALITY_FORMULA_GEOM_1 = "equality_formula_geom_1"
EQUALITY_FORMULA_2 = "equality_formula_2"
EQUALITY_GEOM_3 = "equality_geom_3"
EQUALITY_EQUAL_FORMULA_FULL_1 = "equality_equal_formula_full_1"
EQUALITY_EQUAL_FORMULA_2 = "equality_equal_formula_2"
EQUALITY_FULL_3 = "equality_full_3"
TO_CHECK_4 = "to_check_4"
NO_PREDICTION_5 = "no_prediction_5"
NO_CHANGE_6 = "no_change_6"
31 changes: 17 additions & 14 deletions brdr/geometry_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@
from shapely import get_parts
from shapely import intersection
from shapely import is_empty
from shapely import make_valid
from shapely import polygons
from shapely import symmetric_difference
from shapely import to_wkt
from shapely import unary_union
from shapely import union
from shapely.geometry.base import BaseGeometry
from shapely.prepared import prep

from brdr.constants import MITRE_LIMIT
from brdr.constants import QUAD_SEGMENTS


def buffer_neg_pos(geometry, buffer_value):
def buffer_neg_pos(geometry, buffer_value, mitre_limit=5):
"""
Computes two buffers accordingly: one with a negative buffer value and another with
a positive buffer value. This function can be used the check where relevant areas
Expand Down Expand Up @@ -57,18 +56,18 @@ def buffer_neg_pos(geometry, buffer_value):
buffer(
geometry,
-buffer_value,
quad_segs=QUAD_SEGMENTS,
# quad_segs=QUAD_SEGMENTS,
join_style="mitre",
mitre_limit=MITRE_LIMIT,
mitre_limit=mitre_limit,
),
buffer_value,
quad_segs=QUAD_SEGMENTS,
# quad_segs=QUAD_SEGMENTS,
join_style="mitre",
mitre_limit=MITRE_LIMIT,
mitre_limit=mitre_limit,
)


def buffer_neg(geometry, buffer_value):
def buffer_neg(geometry, buffer_value, mitre_limit=5):
"""
Computes the negative buffer of a given geometric object.
Expand All @@ -95,13 +94,13 @@ def buffer_neg(geometry, buffer_value):
return buffer(
geometry,
-buffer_value,
quad_segs=QUAD_SEGMENTS,
# quad_segs=QUAD_SEGMENTS,
join_style="mitre",
mitre_limit=MITRE_LIMIT,
mitre_limit=mitre_limit,
)


def buffer_pos(geometry, buffer_value):
def buffer_pos(geometry, buffer_value, mitre_limit=5):
"""
Computes the positive buffer of a given geometric object.
Expand All @@ -128,9 +127,9 @@ def buffer_pos(geometry, buffer_value):
return buffer(
geometry,
buffer_value,
quad_segs=QUAD_SEGMENTS,
# quad_segs=QUAD_SEGMENTS,
join_style="mitre",
mitre_limit=MITRE_LIMIT,
mitre_limit=mitre_limit,
)


Expand Down Expand Up @@ -508,6 +507,10 @@ def fill_and_remove_gaps(input_geometry, buffer_value):
return cleaned_geometry


def safe_unary_union(geometries):
return make_valid(unary_union(geometries))


def get_bbox(geometry):
"""
Get the BBOX (string) of a shapely geometry
Expand Down
Loading

0 comments on commit b799fb6

Please sign in to comment.