File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -100,3 +100,27 @@ func FeatureCollectionFromMap(input map[string]interface{}) *FeatureCollection {
100100 }
101101 return result
102102}
103+
104+ // FillProperties iterates through all features to ensure that all properties
105+ // are present on all features to meet the needs of some relational databases
106+ func (fc * FeatureCollection ) FillProperties () {
107+ properties := make (map [string ]bool )
108+
109+ // Loop 1: construct a set (actually a map)
110+ for _ , feature := range fc .Features {
111+ for key := range feature .Properties {
112+ if _ , ok := properties [key ]; ! ok {
113+ properties [key ] = true
114+ }
115+ }
116+ }
117+
118+ // Loop 2: make sure each feature has each property from the set
119+ for _ , feature := range fc .Features {
120+ for key := range properties {
121+ if _ , ok := feature .Properties [key ]; ! ok {
122+ feature .Properties [key ] = nil
123+ }
124+ }
125+ }
126+ }
You can’t perform that action at this time.
0 commit comments