Skip to content

Commit 85e83df

Browse files
committed
add point location in search result
1 parent f76cf1d commit 85e83df

File tree

5 files changed

+41
-4
lines changed

5 files changed

+41
-4
lines changed

mada/commune.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type Commune struct {
1818
District string `json:"district"`
1919
Country string `json:"country"`
2020
Coordinates [][]geom.Coord `json:"coordinates"`
21+
Point geom.Coord `json:"point,omitempty"`
2122
}
2223

2324
type CommuneService struct {

mada/district.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type District struct {
1717
Region string `json:"region"`
1818
Country string `json:"country"`
1919
Coordinates [][]geom.Coord `json:"coordinates"`
20+
Point geom.Coord `json:"point,omitempty"`
2021
}
2122

2223
type DistrictService struct {

mada/fokontany.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
)
1414

1515
type Fokontany struct {
16+
Point geom.Coord `json:"point,omitempty"`
1617
ID string `json:"id"`
1718
Name string `json:"name"`
1819
Commune string `json:"commune"`

mada/region.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type Region struct {
1616
Name string `json:"name"`
1717
Country string `json:"country"`
1818
Coordinates [][]geom.Coord `json:"coordinates"`
19+
Point geom.Coord `json:"point,omitempty"`
1920
}
2021

2122
type RegionService struct {

mada/search.go

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,14 @@ func searchInFokontany(db *sql.DB, area olc.CodeArea, opt SearchOptions) bool {
125125
District: district,
126126
Country: country,
127127
Coordinates: p.(*geom.Polygon).Coords(),
128+
Point: geom.NewPoint(geom.XY).MustSetCoords(geom.Coord{area.LngLo, area.LatLo}).Coords(),
128129
}, "", " ")
129130
fmt.Println(string(b))
130131
return noresults
131132
}
132133
fmt.Printf(`
134+
point
135+
%v
133136
id
134137
%s
135138
name
@@ -146,7 +149,7 @@ func searchInFokontany(db *sql.DB, area olc.CodeArea, opt SearchOptions) bool {
146149
fokontany
147150
geometry
148151
%v
149-
`, uid, name, commune, district, region, country, p.(*geom.Polygon).Coords())
152+
`, geom.NewPoint(geom.XY).MustSetCoords(geom.Coord{area.LngLo, area.LatLo}).Coords(), uid, name, commune, district, region, country, p.(*geom.Polygon).Coords())
150153

151154
}
152155
return noresults
@@ -175,11 +178,14 @@ func searchInCommune(db *sql.DB, area olc.CodeArea, opt SearchOptions) bool {
175178
District: district,
176179
Country: country,
177180
Coordinates: p.(*geom.Polygon).Coords(),
181+
Point: geom.NewPoint(geom.XY).MustSetCoords(geom.Coord{area.LngLo, area.LatLo}).Coords(),
178182
}, "", " ")
179183
fmt.Println(string(b))
180184
return noresults
181185
}
182186
fmt.Printf(`
187+
point
188+
%v
183189
id
184190
%s
185191
name
@@ -194,7 +200,15 @@ func searchInCommune(db *sql.DB, area olc.CodeArea, opt SearchOptions) bool {
194200
commune
195201
geometry
196202
%v
197-
`, uid, name, district, region, country, p.(*geom.Polygon).Coords())
203+
`,
204+
geom.NewPoint(geom.XY).MustSetCoords(geom.Coord{area.LngLo, area.LatLo}).Coords(),
205+
uid,
206+
name,
207+
district,
208+
region,
209+
country,
210+
p.(*geom.Polygon).Coords(),
211+
)
198212

199213
}
200214
return noresults
@@ -222,11 +236,14 @@ func searchInDistrict(db *sql.DB, area olc.CodeArea, opt SearchOptions) bool {
222236
Region: region,
223237
Country: country,
224238
Coordinates: p.(*geom.Polygon).Coords(),
239+
Point: geom.NewPoint(geom.XY).MustSetCoords(geom.Coord{area.LngLo, area.LatLo}).Coords(),
225240
}, "", " ")
226241
fmt.Println(string(b))
227242
return noresults
228243
}
229244
fmt.Printf(`
245+
point
246+
%v
230247
id
231248
%s
232249
name
@@ -239,7 +256,14 @@ func searchInDistrict(db *sql.DB, area olc.CodeArea, opt SearchOptions) bool {
239256
district
240257
geometry
241258
%v
242-
`, uid, name, region, country, p.(*geom.Polygon).Coords())
259+
`,
260+
geom.NewPoint(geom.XY).MustSetCoords(geom.Coord{area.LngLo, area.LatLo}).Coords(),
261+
uid,
262+
name,
263+
region,
264+
country,
265+
p.(*geom.Polygon).Coords(),
266+
)
243267

244268
}
245269
return noresults
@@ -266,11 +290,14 @@ func searchInRegion(db *sql.DB, area olc.CodeArea, opt SearchOptions) bool {
266290
Name: name,
267291
Country: country,
268292
Coordinates: p.(*geom.Polygon).Coords(),
293+
Point: geom.NewPoint(geom.XY).MustSetCoords(geom.Coord{area.LngLo, area.LatLo}).Coords(),
269294
}, "", " ")
270295
fmt.Println(string(b))
271296
return noresults
272297
}
273298
fmt.Printf(`
299+
point
300+
%v
274301
id
275302
%s
276303
name
@@ -281,7 +308,13 @@ func searchInRegion(db *sql.DB, area olc.CodeArea, opt SearchOptions) bool {
281308
region
282309
geometry
283310
%v
284-
`, uid, name, country, p.(*geom.Polygon).Coords())
311+
`,
312+
geom.NewPoint(geom.XY).MustSetCoords(geom.Coord{area.LngLo, area.LatLo}).Coords(),
313+
uid,
314+
name,
315+
country,
316+
p.(*geom.Polygon).Coords(),
317+
)
285318

286319
}
287320
return noresults

0 commit comments

Comments
 (0)