I have a system where a user can upload a SHP through a web form. I upload this SHP and import it to GeoServer via REST API. Later the user can interact with the data using a web client with OpenLayers.

Even though the property fields in the SHP are specified by the requirements I'm having lots of issues regarding the case sensitiveness of feature's property names. So, some of the SHP include features with a property called LENGTH, or length, or Length...

I'm wondering if there's an easy way to set OpenLayers in some kind of case-insensitive mode or if should I iterate all features when importing to GeoServer to convert all properties to lowercase (or uppercase, it doesn't really matter)

Edit: Answering notkilroy's comment, the problem is that my features' properties appear as undefined if they I check them lowercased but in the shapefile are in any other case form.

 * Assume the loaded SHP has all properties defined UPPERCASE in this case

var Properties = {
    LENGTH: 'length',

var featureLength = feature.getProperties()[Properties.LENGTH]; // undefined

var featureLength = feature.get(Properties.LENGTH); // undefined
  • What problems is the case sensitivity causing? I can imagine that losing case could actually cause readability problems if a field used camel casing.
    – Emily
    Dec 20, 2017 at 15:59
  • Thanks @notkilroy. I updated my question answering your comment Dec 20, 2017 at 16:08

2 Answers 2


As you suspected, running checks to make sure that uploaded files meet your standards is probably necessary. You could either automatically force a particular case, or just return a list of non-compliant fields and the rule the violate to the user to correct. You likely have more requirements beyond just the case sensitivity (like required fields) that you'll want to implement.

Alternately, you could use the feature.getProperties() method to iterate over all properties and create an additional dictionary that does the mapping from a standardized field name to the one in the shapefile, similar to what you provided in your code sample.

  • Thanks for your ideas! How do you check the properties of the uploaded shapefile before publishing it to GeoServer via REST API? Dec 21, 2017 at 17:23
  • You'll likely need a server that receives the shapefile, pre-processes it, and then uploads to GeoServer.
    – Emily
    Dec 21, 2017 at 17:28
  • Well, I got that... I mean, shapefile is uploaded with an <input type="file">, received with PHP ($_FILES) and then send to GeoServer via API using cURL. I meant if you know an easy way to manipulate the SHP in the middle server using PHP to check for the required feature properties, letter case, etc. Thank you! Dec 21, 2017 at 17:40
  • You'll need to find a geospatial package for PHP that reads/writes shapefiles.
    – Emily
    Dec 21, 2017 at 17:46
  • 1
    @JordiNebot Or at the very least find a PHP library that can manipulate dBase (there seems to be some), and change the fields in the dbf file; creating your own middleware.
    – RomaH
    Dec 27, 2017 at 19:15

Given that Feature#getProperties returns a plain JavaScript Object you could use a function (similar to those proposed here: https://stackoverflow.com/a/33159592/526860) if you're only interested in reading properties:

function getProperty (obj, prop) {
    var key;
    for (key in obj) {
        if (key.toLowerCase() == prop.toLowerCase()) {
            return obj[key];

To get the length property regardless of case you would do:

var featureLength = getProperty(feature.getProperties(), 'length')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.