teksi / district_heating

Future TEKSI distance heating module
https://teksi.github.io/district_heating/
GNU General Public License v3.0
0 stars 0 forks source link

Support several geometry types for lines (pipe_section, cables) and for polygons (structure, trench) #39

Closed jpdupuy closed 3 months ago

jpdupuy commented 5 months ago

The current defintion prevents FME to import geopackage data id the geometry constraint is based on a unique geometry type ALTER TABLE tdh_od.pipe_section ADD COLUMN geometry3d_geometry geometry('COMPOUNDCURVEZ', :SRID); ALTER TABLE tdh_od.structure ADD COLUMN geometry3d_geometry geometry('CURVEPOLYGONZ', :SRID);

Whenever the geopackage is made of strait lines (Linestring) or strait lines + arcs (compoundcurve) fme stops with a fatal error : ERROR |Bulk copy failed on table 'tdh_od.pipe_section' using delimiter ':'. Error was 'ERROR: Geometry type (LineString) does not match column type (CompoundCurve) CONTEXT: COPY pipe_section, line 1, column geometry3d_geometry: "01020000A008080000030000009AB114071E4843411E47ECD42A8F31...' ERROR |POSTGIS writer: An error has occurred. Check the logfile above for details

I could not find a solution to solve this issue (The ArcStrocker would transform arcs into line segments, but you would have to change the constraint to a LINESTRINGZ in the datamodel).

I suggest to add the following constraints ALTER TABLE tdh_od.pipe_section ADD COLUMN geometry3d_geometry geometry('GEOMETRYZ', :SRID); ALTER TABLE tdh_od.pipe_section ADD CONSTRAINT enforce_pipe_section_geotype_geometry3d CHECK (geometrytype(geometry3d_geometry) = 'LINESTRING'::TEXT OR geometrytype(geometry3d_geometry) = 'COMPOUNDCURVE'::TEXT OR geometrytype(geometry3d_geometry) = 'LINESTRINGZ'::TEXT OR geometrytype(geometry3d_geometry) = 'COMPOUNDCURVEZ'::TEXT);

ALTER TABLE tdh_od.sia405cc_cable ADD COLUMN geometry3d_geometry geometry('GEOMETRYZ', :SRID); ALTER TABLE tdh_od.sia405cc_cable ADD CONSTRAINT enforce_cable_geotype_geometry3d CHECK (geometrytype(geometry3d_geometry) = 'LINESTRING'::TEXT OR geometrytype(geometry3d_geometry) = 'COMPOUNDCURVE'::TEXT OR geometrytype(geometry3d_geometry) = 'LINESTRINGZ'::TEXT OR geometrytype(geometry3d_geometry) = 'COMPOUNDCURVEZ'::TEXT);

ALTER TABLE tdh_od.structure ADD COLUMN geometry3d_geometry geometry('GEOMETRYZ', :SRID); ALTER TABLE tdh_od.structure ADD CONSTRAINT enforce_structure_geotype_geometry3d CHECK (geometrytype(geometry3d_geometry) = 'POLYGON'::TEXT OR geometrytype(geometry3d_geometry) = 'CURVEPOLYGON'::TEXT
OR geometrytype(geometry3d_geometry) = 'POLYGONZ'::TEXT OR geometrytype(geometry3d_geometry) = 'CURVEPOLYGONZ'::TEXT); Please find a zip file to reproduce the error fme_scripts.zip

ponceta commented 3 months ago

image

Update writer and add the destination format as compoundcurve (FME will handle 2D 3D automatically)

image

jpdupuy commented 3 months ago

Thanks, it works fine now. When updating the writer, do not forget to uncheck "Create Generic Spatial Column" and geometry column name=geometry3d_geometry