camptocamp / ogc-client

A TypeScript library for interacting with geospatial services
https://camptocamp.github.io/ogc-client/
BSD 3-Clause "New" or "Revised" License
66 stars 12 forks source link

Incorrect Handling of the properties Field in parseFeatureTypeInfo #75

Closed paulemilechilin closed 1 month ago

paulemilechilin commented 1 month ago

When calling the parseFeatureTypeInfo function, there is a problem with how the properties field is handled. Currently, the logic to parse the properties only processes elements where the type attribute starts with xsd:. This results in certain elements being excluded if their type does not follow this pattern, causing incomplete or incorrect feature type information. Proposed Solution: remove .startsWith('xsd:') on getElementAttribute(el, 'type')

paulemilechilin commented 1 month ago

More details : The current implementation only includes elements where the type attribute starts with xsd:. However, in some cases, the type prefix may start with xs: instead, causing relevant elements to be omitted from properties. current implementation : const properties = typeElementsEls .filter((el) => getElementAttribute(el, 'type').startsWith('xsd:')) .reduce( (prev, curr) => ({ ...prev,

    getElementAttribute(curr, 'type')
  ),
}),

);

proposed implementation : something like : const properties = typeElementsEls .filter((el) => /^xsd:|^xs:/.test(getElementAttribute(el, 'type'))) .reduce( (prev, curr) => ({ ...prev,

    getElementAttribute(curr, 'type')
  ),
}),
{}

);

jahow commented 1 month ago

Thank you for the suggestions! I implemented it. Let me know if that works for you!