comparison pkg/imports/fm.go @ 4967:3f704ebad0c5 fairway-marks-import

Follow-up of rev. 1b309a8e7673 for DAYMAR
author Tom Gottfried <tom@intevation.de>
date Fri, 28 Feb 2020 16:18:44 +0100
parents 58dc06e91c39
children 1ba11ade2cf3
comparison
equal deleted inserted replaced
4966:3530d91c3da3 4967:3f704ebad0c5
106 Marsys *int64 `json:"hydro_marsys"` 106 Marsys *int64 `json:"hydro_marsys"`
107 Boyshp *int `json:"hydro_boyshp"` 107 Boyshp *int `json:"hydro_boyshp"`
108 Catspm *string `json:"hydro_catspm"` 108 Catspm *string `json:"hydro_catspm"`
109 } 109 }
110 110
111 daymarProperties struct { 111 daymarHydroProperties struct {
112 fairwayMarksProperties 112 fairwayMarksProperties
113 Colour *string `json:"hydro_colour"` 113 Colour *string `json:"hydro_colour"`
114 Colpat *string `json:"hydro_colpat"` 114 Colpat *string `json:"hydro_colpat"`
115 Condtn *int `json:"hydro_condtn"` 115 Condtn *int `json:"hydro_condtn"`
116 Dirimp *string `json:"ienc_dirimp,omitempty"` 116 Topshp *int `json:"hydro_topshp"`
117 Topshp *int `json:"hydro_topshp"` 117 }
118 Orient *float64 `json:"hydro_orient,omitempty"` 118
119 daymarIencProperties struct {
120 daymarHydroProperties
121 Dirimp *string `json:"ienc_dirimp"`
122 Orient *float64 `json:"hydro_orient"`
119 } 123 }
120 124
121 lightsProperties struct { 125 lightsProperties struct {
122 fairwayMarksProperties 126 fairwayMarksProperties
123 Colour *string `json:"hydro_colour"` 127 Colour *string `json:"hydro_colour"`
176 BOYLATHYDROJobKind JobKind = "fm_boylat_hydro" 180 BOYLATHYDROJobKind JobKind = "fm_boylat_hydro"
177 BOYLATIENCJobKind JobKind = "fm_boylat_ienc" 181 BOYLATIENCJobKind JobKind = "fm_boylat_ienc"
178 BOYCARJobKind JobKind = "fm_boycar" 182 BOYCARJobKind JobKind = "fm_boycar"
179 BOYSAWJobKind JobKind = "fm_boysaw" 183 BOYSAWJobKind JobKind = "fm_boysaw"
180 BOYSPPJobKind JobKind = "fm_boyspp" 184 BOYSPPJobKind JobKind = "fm_boyspp"
181 DAYMARJobKind JobKind = "fm_daymar" 185 DAYMARHYDROJobKind JobKind = "fm_daymar_hydro"
186 DAYMARIENCJobKind JobKind = "fm_daymar_ienc"
182 LIGHTSJobKind JobKind = "fm_lights" 187 LIGHTSJobKind JobKind = "fm_lights"
183 NOTMRKJobKind JobKind = "fm_notmrk" 188 NOTMRKJobKind JobKind = "fm_notmrk"
184 RTPBCNJobKind JobKind = "fm_rtpbcn" 189 RTPBCNJobKind JobKind = "fm_rtpbcn"
185 TOPMARJobKind JobKind = "fm_topmar" 190 TOPMARJobKind JobKind = "fm_topmar"
186 ) 191 )
294 createInvalidation("boyspp"), 299 createInvalidation("boyspp"),
295 func() interface{} { return new(boysppProperties) }, 300 func() interface{} { return new(boysppProperties) },
296 ), 301 ),
297 }) 302 })
298 303
299 RegisterJobCreator(DAYMARJobKind, 304 RegisterJobCreator(DAYMARHYDROJobKind,
300 &PointWFSJobCreator{ 305 &PointWFSJobCreator{
301 description: "fairway marks daymar", 306 description: "fairway marks daymar (HYDRO)",
302 depends: [2][]string{{"fairway_marks_daymar"}, {}}, 307 depends: [2][]string{{"fairway_marks_daymar_hydro"}, {}},
303 newConsumer: newSQLConsumer( 308 newConsumer: newSQLConsumer(
304 prepareStmnts( 309 prepareStmnts(
305 createInsertFMSQL("daymar", 310 createInsertFMSQL("daymar_hydro",
311 "colour", "colpat", "condtn", "topshp"),
312 ),
313 consumeDAYMARHydro,
314 createInvalidation("daymar_hydro"),
315 func() interface{} { return new(daymarHydroProperties) },
316 ),
317 })
318
319 RegisterJobCreator(DAYMARIENCJobKind,
320 &PointWFSJobCreator{
321 description: "fairway marks daymar (IENC)",
322 depends: [2][]string{{"fairway_marks_daymar_ienc"}, {}},
323 newConsumer: newSQLConsumer(
324 prepareStmnts(
325 createInsertFMSQL("daymar_ienc",
306 "colour", "colpat", "condtn", "topshp", "orient"), 326 "colour", "colpat", "condtn", "topshp", "orient"),
307 insertDaymarDirimpSQL, 327 insertDaymarDirimpSQL,
308 ), 328 ),
309 consumeDAYMAR, 329 consumeDAYMARIenc,
310 createInvalidation("daymar"), 330 createInvalidation("daymar_ienc"),
311 func() interface{} { return new(daymarProperties) }, 331 func() interface{} { return new(daymarIencProperties) },
312 ), 332 ),
313 }) 333 })
314 334
315 RegisterJobCreator(LIGHTSJobKind, 335 RegisterJobCreator(LIGHTSJobKind,
316 &PointWFSJobCreator{ 336 &PointWFSJobCreator{
865 return ErrFeatureIgnored 885 return ErrFeatureIgnored
866 } 886 }
867 return nil 887 return nil
868 } 888 }
869 889
870 func consumeDAYMAR( 890 func consumeDAYMARHydro(
871 spc *SQLPointConsumer, 891 spc *SQLPointConsumer,
872 points pointSlice, 892 points pointSlice,
873 properties interface{}, 893 properties interface{},
874 epsg int, 894 epsg int,
875 ) error { 895 ) error {
876 props := properties.(*daymarProperties) 896 props := properties.(*daymarHydroProperties)
897
898 var fmid int64
899 err := spc.savepoint(func() error {
900 return spc.stmts[0].QueryRowContext(
901 spc.ctx,
902 points.asWKB(),
903 epsg,
904 props.Datsta,
905 props.Datend,
906 props.Persta,
907 props.Perend,
908 props.Objnam,
909 props.Nobjnm,
910 props.Inform,
911 props.Ninfom,
912 props.Scamin,
913 props.Picrep,
914 props.Txtdsc,
915 props.Sordat,
916 props.Sorind,
917 props.Colour,
918 props.Colpat,
919 props.Condtn,
920 props.Topshp,
921 ).Scan(&fmid)
922 })
923 switch {
924 case err == sql.ErrNoRows:
925 return ErrFeatureDuplicated
926 // ignore -> filtered by responsibility area or a duplicate
927 case err != nil:
928 spc.feedback.Error(pgxutils.ReadableError{Err: err}.Error())
929 return ErrFeatureIgnored
930 }
931 return nil
932 }
933
934 func consumeDAYMARIenc(
935 spc *SQLPointConsumer,
936 points pointSlice,
937 properties interface{},
938 epsg int,
939 ) error {
940 props := properties.(*daymarIencProperties)
877 941
878 var fmid int64 942 var fmid int64
879 err := spc.savepoint(func() error { 943 err := spc.savepoint(func() error {
880 return spc.stmts[0].QueryRowContext( 944 return spc.stmts[0].QueryRowContext(
881 spc.ctx, 945 spc.ctx,