Repository navigation
Give IP Intelligence latitude, longitude and WKT points to 3 decimal places - #62
Merged
Merged
Conversation
…places The Rounding of Azimuth and Declination values section of the value types page says a location is given to 3 decimal places, as a number, as a string and as a point in a WKT shape. The engine asked for 16 decimal places in WKT and gave latitude and longitude as the native engine returned them.
jwrosewell
force-pushed
the
align/ipi-decimals
branch
from
November 9, 2026 23:58
b6c1aef to
9d18b56
Compare
…type Go and Rust ask the C library which stored type a value came from and round an Azimuth or a Declination. The swig results give no stored type, so the two properties the IP Intelligence data model gives as those types are named.
jwrosewell
marked this pull request as ready for review
November 11, 2026 15:11
This was referenced Nov 11, 2026
Merged
Draft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
IP Intelligence gave Latitude and Longitude with every digit the double
carried, so a value stored as a Declination came back as
18.542741172521133where the specification asks for18.543. WKT shapeswere worse, because
swigData.js
asked the C library for 16 decimal places on every point of every shape, and
an area can hold many points, so each string was far longer than the data it
carried.
Go and Rust already round, so the same address gave a different number in each
language.
What the specification says
value-types.md, Rounding of Azimuth and Declination values,
at the fixed commit 8aa2de01 on
rc.data-model.md
at the same commit applies it to the IP Intelligence properties.
Change
swigData.js
defaultWktDecimalPlaces, which was 16, becomesdefaultDecimalPlaces,which is 3, and is both the places a number is rounded to and the places
asked of
getValuesAsWeightedWKTStringList. The WKT points therefore comeback at 3 places from the C library, which is where they are made.
roundLocationformats the double to 3 places and reads it back, whichgives the binary floating point number nearest to the rounded decimal, as
the page asks. It adds zero, so a value that rounds to zero from below, such
as
-0.0004, is given as0rather than-0. A caller can tell the twoapart with
Object.is, and dividing into them givesInfinityagainst-Infinity.51degrees-go#88 made the
same choice and gives the reason that the C library writes such a value as
text as
0, so the number agrees with the text. The page does not say whichzero to give.
getInternalrounds each weighted value of aweightedsingleorweighteddoubleproperty namedlatitudeorlongitude. The weight andthe raw weight are untouched.
getInternalIgnoringCase, whichrcadded,calls
getInternal, so a read in any letter case is rounded too.Why the properties are named rather than found by their stored type
Go and Rust ask the C library which stored type each value came from and round
any Azimuth or Declination, Go with
fiftyoneDegreesPropertyGetStoredTypeByIndexand Rust with a new shimfunction. The swig results Node has give no stored type, and adding one would
be a change to the C library and the generated wrappers, so the two properties
the IP Intelligence data model gives as those types are named in
locationPropertiesinstead. The comment above the list says so. A propertyadded later whose values are stored as an Azimuth or a Declination would
therefore not be rounded in Node until it is named, which is listed under what
remains.
A property declared as text already comes through the C library's string
converter at 3 places, which is the finding
51degrees-go#88 records,
so the text route needed no change here either.
The same change in the other languages
isCoordinateThe Python twin,
51degrees-python#81,
was moved to next week on 10 November.
Tests
swigDataDecimalPlaces.test.js
drives
SwigDatawith a stand in for the swig results, so it needs no datafile and no native build.
are given to 3 decimal placesuses the page's own example,18.542741172521133 for Latitude, and checks it is given as 18.543. Longitude
is -0.0004 and is given as 0, with
Object.is(value, -0)false.are the number nearest to the rounded decimalchecks 51.5074567 and-0.1277583 give 51.507 and -0.128, and that the weight is unchanged.
leave other properties as the engine gives themchecks a thirdweighteddoubleproperty named Other keeps all its digits.asks for WKT with 3 decimal placesrecords whatgetValuesAsWeightedWKTStringListwas asked for and checks it was['Areas', 3].Red. Run 43021053852,
on
tmp/node-62-red2, which isrcat 8b9fc3d with this test file and nothingelse from the branch. 3 of the 4 failed, the first with
Expected: 18.543, Received: 18.542741172521133. The one that passed isleave other properties as the engine gives them, which is the test that asksfor no rounding.
An earlier attempt,
run 43020248306,
failed before any test ran because its workflow did not check out the
javascript-templatessubmodule. It proves nothing and is named here only soit is not read as a second red.
Green. Run 43026297138,
on
tmp/node-62-green2, which is this head. 4 of 4 passed.Full build. Run 43026212927,
on
tmp/pr-matrix-62-g, success. Every one of its sevenSetting 'PullRequestSha'lines reads6ffa23b68c0f68497567694f47e5edd4997955a9, which is this head. Configureprinted "Left out 2 macOS entries". The branch it built from was
rcatca51908, and
rchas moved on since. Nothingrchas taken since touches thetwo files this changes, and the draft merges into the current
rcwith noconflict.
macOS was left out of this draft's full build under the 9 November decision.
The rc head is built with macOS before it merges into main.
What remains
default is 3. Node has a constant and no setting, which is deliberate and
matches Go and Rust, neither of which offers one either. It is not an
oversight.
above. Closing that gap needs an accessor for the stored type in the C
library and the generated wrappers, as
51degrees-go#88 and
51degrees-rust#287
have. No issue is open for it yet.