The pipeline has read regions out of MapGenie captures since the beginning, but the translated sources could only ever say they had none: mgdoc spelled Regions as a slice of nothing. It is now a real type -- title, subtitle, and GeoJSON-shaped polygon features in the same synthetic coordinates a pin speaks -- matching what the generator's decoder already reads. The three existing translators still emit the empty slice they always did, byte for byte, so no stamp moves; the difference is that the next source can name ground.
- commit
- ef7a9d21ab4dc5a99e453afddb9c03986171fdf8
- parent
- 56800ad9766c00d03313103e32be1b3e737b20af
- author
- Dami <dami.etoile@gmail.com>
| M | internal/ | 2 | +- |
| M | internal/ | 29 | ++++++++++++++++++++++++++++- |
| M | internal/ | 2 | +- |
| M | internal/ | 2 | +- |
@@ -160,7 +160,7 @@ func Translate(doc []byte) ([]byte, error) {
160160 Slug: capture.ObjectSlug,161161 },162162 Groups: groups,163- Regions: []struct{}{},163+ Regions: []mgdoc.Region{},164164 }165165 return json.Marshal(out)166166 }@@ -8,6 +8,7 @@
88 package mgdoc99 1010 import (11+ "encoding/json"1112 "fmt"1213 "hash/fnv"1314 "math"@@ -39,10 +40,36 @@ type Map struct {
3940 Config Config `json:"config"`4041 Game Game `json:"game"`4142 Groups []Group `json:"groups"`42- Regions []struct{} `json:"regions"`43+ Regions []Region `json:"regions"`4344 Attrs map[string]string `json:"atlas_attrs,omitempty"`4445 }4546 47+// Region is a named piece of ground: the generator reads it into a zone, and48+// its features carry GeoJSON-shaped polygon geometry whose positions are the49+// same synthetic longitude and latitude a pin speaks. Sources without ground50+// to name leave the slice empty rather than absent, which is the shape a real51+// MapGenie capture spells.52+type Region struct {53+ ID int64 `json:"id"`54+ Title string `json:"title"`55+ Subtitle string `json:"subtitle,omitempty"`56+ ParentRegionID *int64 `json:"parent_region_id,omitempty"`57+ CenterX *float64 `json:"center_x,omitempty"`58+ CenterY *float64 `json:"center_y,omitempty"`59+ Features []RegionFeature `json:"features,omitempty"`60+}61+62+type RegionFeature struct {63+ Geometry Geometry `json:"geometry"`64+}65+66+// Geometry is the GeoJSON slice of a region feature: Polygon or MultiPolygon,67+// coordinates kept raw because the generator passes them through verbatim.68+type Geometry struct {69+ Type string `json:"type"`70+ Coordinates json.RawMessage `json:"coordinates"`71+}72+4673 type Game struct {4774 ID int64 `json:"id"`4875 Title string `json:"title"`@@ -219,7 +219,7 @@ func Translate(doc []byte) ([]byte, error) {
219219 Slug: capture.GameSlug,220220 },221221 Groups: groups,222- Regions: []struct{}{},222+ Regions: []mgdoc.Region{},223223 }224224 return json.Marshal(out)225225 }@@ -213,7 +213,7 @@ func Translate(doc []byte) ([]byte, error) {
213213 Slug: capture.Body,214214 },215215 Groups: groups,216- Regions: []struct{}{},216+ Regions: []mgdoc.Region{},217217 }218218 return json.Marshal(out)219219 }