Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Make measure layer queryable #2078

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jokd
Copy link
Contributor

@jokd jokd commented Nov 8, 2024

Fixes #2076

@Grammostola
Copy link
Contributor

Grammostola commented Nov 20, 2024

Hi, nice addition!
I've two observations:

  • It doesn't appear to work on buffers
  • The area and length measurements in the infowindow (numbers) could be localized (you've already localized the text)

@jokd
Copy link
Contributor Author

jokd commented Dec 2, 2024

Hi, nice addition! I've two observations:

  • It doesn't appear to work on buffers
    That is because buffers are points with a radius style, hence got no area. We did something similar in the style window but I remember the figures being a bit off and needs some rework.
  • The area and length measurements in the infowindow (numbers) could be localized (you've already localized the text)
    That formatting is not in the measure control but in the attribute handling. (It would also be nice if zero rows were omitted, eg area for lines.)

@Grammostola
Copy link
Contributor

Grammostola commented Dec 2, 2024

That formatting is not in the measure control but in the attribute handling. (It would also be nice if zero rows were omitted, eg area for lines.)

I see, the numeral and unit is returned via the @length and @area functions..wherever they are defined (I had a quick look and it seemed entirely cryptic) ..for yes those functions would need to be modified to return a localized numeral. Point me in a direction and I can have a look.

Edit. Right, utils/formatareastring.js and formatlengthstring.js need to be localized ...via getattributes.js, selecteditem.js, featureinfo.js and the viewer I think

@jokd
Copy link
Contributor Author

jokd commented Dec 3, 2024

That formatting is not in the measure control but in the attribute handling. (It would also be nice if zero rows were omitted, eg area for lines.)

I see, the numeral and unit is returned via the @length and @area functions..wherever they are defined (I had a quick look and it seemed entirely cryptic) ..for yes those functions would need to be modified to return a localized numeral. Point me in a direction and I can have a look.

Edit. Right, utils/formatareastring.js and formatlengthstring.js need to be localized ...via getattributes.js, selecteditem.js, featureinfo.js and the viewer I think

src/geometry/getarea and /getlength seems to be used by the replacer

@Grammostola
Copy link
Contributor

Indeed. And it is possibly the replacer that needs to become aware of "null" results from getArea, getLength.
Either way for clarity I am working on localizing the relevant numbers (probably via

    attributes: [
      { html: `${locLength}: {{@length(1)}}`,
        localization },
      { html: `${locArea}: {{@area(1)}}`,
        localization }
    ],

even if it looks a little funny to send the loc object for every instance of html use. It seems the less potentially disruptive way)

as well as making something aware in order to not show 0.0 results.

@Grammostola
Copy link
Contributor

Info on a polygon should not include "Length: 0.0" now and vice versa for area.

In order to achieve this some things were changed:

  • the getArea() and getLength() functions now return 0 instead of a formatted text string when the length measured is 0 (there's no need to format the response if it is 0, the rationale is)
  • the html method of getAttributes now returns null instead of a new element with null inside (the latter seemed pointless)
  • the replacer method will return null if it received 0 from getArea() or getLength()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make measure queryable
2 participants