MapServer icon indicating copy to clipboard operation
MapServer copied to clipboard

Encoding of shapefile breaks OGCAPI: Features (both HTML and JSON response)

Open jmckenna opened this issue 1 year ago • 0 comments

(this was very difficult to isolate, but I did, took me over a week ha, to isolate this to one single record, with 3 attributes only: name, id, and name_hu where name_hu is Tanzánia)

Declaration: this could be just for my documentation job for mapserver.org, ha, instead of an "issue" here, but, at least by reporting this here other readers will be warned before they hit this wall, which will likely save them a week of effort.

Description

  • testing with main branch, on Windows
  • this same record works great inside a database (PostgreSQL, SpatiaLite) and served through OGCAPI: Features
  • this same record works great served through OGC: WFS (as a Shapefile, PostgreSQL, SpatiaLite)
  • however in testing these past few weeks, using the same dataset but in ESRI Shapefile format, breaks the OGCAPI: Features response

Symptom 1

  • request: ogcapi/collections/countries/items?f=html
  • response: {"code":"ServerError","description":"General template handling error."}
    • yes the response is in JSON even though the request is for HTML

Symptom 2

  • request: /ogcapi/collections/countries/items?f=json
  • response: blank (literally no response, as shown in browser Developer Tools)

Solution attempt # 100

  • change encoding in the templates (header.html, openapi.html) from <meta charset="utf-8" /> to <meta charset="ISO-8859-1" />
  • result: no change, same errors

Solution attempt # 101

  • in the mapfile LAYER section, add ENCODING "ISO-8859-1"
  • result: fixes both the JSON and HTML item response

Are you interested in trying this locally? Here is that single record shapefile (it is only 2KB in size, at it is one polygon feature with 1 record) : https://gatewaygeomatics.com/dl/ogcapi-features-shp.zip

(I also realize that I just spent a week on creating what could be the perfect new shapefile for a new msautotest, ha, yikes)

jmckenna avatar Sep 25 '22 16:09 jmckenna