feat: Remove redundant GeoJSON formats and return only mapped result for vector_with_kato

This commit is contained in:
2026-07-01 17:29:22 +05:00
parent 6113202704
commit ec8a014e82
5 changed files with 35 additions and 231 deletions

View File

@@ -37,7 +37,6 @@ func (h *DatasetHandler) Register(r chi.Router) {
r.Post("/", h.upload)
r.Get("/{id}", h.get)
r.Get("/{id}.geojson", h.geojson)
r.Get("/{id}.kato.geojson", h.katoGeoJSON)
r.Get("/{id}/status", h.status)
r.Get("/{id}/download", h.download)
r.Post("/{id}/mapping", h.mapping)
@@ -305,10 +304,11 @@ func (h *DatasetHandler) get(w http.ResponseWriter, r *http.Request) {
httputil.WriteJSON(w, http.StatusOK, dataset)
}
// geojson returns the dataset as a GeoJSON FeatureCollection (RFC 7946). For a
// vector_with_kato dataset it serves the dataset's own geometry as a single
// feature when present, otherwise one feature per KATO joined to the districts
// table. Only vector_with_kato datasets are supported.
// geojson returns the dataset as a GeoJSON FeatureCollection (RFC 7946). A
// vector_with_kato dataset always ignores its own geometry and instead joins the
// districts table on KATO code: one feature per KATO with the observation values
// mapped onto its district polygon. A plain vector dataset serves its own
// geometry as a single feature.
func (h *DatasetHandler) geojson(w http.ResponseWriter, r *http.Request) {
id, ok := parseUUIDParam(w, r, "id")
if !ok {
@@ -324,25 +324,6 @@ func (h *DatasetHandler) geojson(w http.ResponseWriter, r *http.Request) {
_ = json.NewEncoder(w).Encode(fc)
}
// katoGeoJSON returns the dataset as a GeoJSON FeatureCollection (RFC 7946),
// ignoring any geometry the dataset carries and instead joining the districts
// table on KATO code: one feature per KATO with the observation values mapped
// onto its district polygon. Only vector_with_kato datasets are supported.
func (h *DatasetHandler) katoGeoJSON(w http.ResponseWriter, r *http.Request) {
id, ok := parseUUIDParam(w, r, "id")
if !ok {
return
}
fc, err := h.svc.KatoGeoJSON(r.Context(), id)
if err != nil {
respondDomainError(w, err)
return
}
w.Header().Set("Content-Type", "application/geo+json")
w.WriteHeader(http.StatusOK)
_ = json.NewEncoder(w).Encode(fc)
}
func (h *DatasetHandler) download(w http.ResponseWriter, r *http.Request) {
id, ok := parseUUIDParam(w, r, "id")
if !ok {