Jump to content
cst989

Filtering pages where field value is greater than a negative number

Recommended Posts

Hello

I'm having an issue with filtering on a negative longitude value.

My search filter looks like this (decimal places have been shortened for the example)

$pages->find("template=skyscraper,longitude>=-0.1011,longitude<=0.0708,limit=10,sort=created");

Now lets say I have two pages, one has a longitude of 0.05, this one is found.

Another has a longitude of -0.05, this one is not found, even though -0.05 is still greater than -0.1011...

Share this post


Link to post
Share on other sites

As always I work this out after 30 mins of trying, but always 2 mins after posting on a forum 😛

It was because the field type must be float. Funnily enough it works fine if it's Text, until you hit a negative number. I will leave this up for anyone who makes the same mistake as me.

  • Like 2

Share this post


Link to post
Share on other sites
7 hours ago, cst989 said:

It was because the field type must be float.

From past experience working with lat/lng coordinates, I suggest using a decimal field for these. Float fields only have a precision of 6 figures which is often not sufficient for a lat/lng value.

  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...