teksi / district_heating

Future TEKSI distance heating module
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

Open jpdupuy opened 3 weeks ago

jpdupuy commented 3 weeks 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