pydantic / pydantic-extra-types

Extra Pydantic types.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add `Latitude` and `Longitude` type

miili opened this issue · comments

commented
  • Latitude degree
  • Longitude degree

Could also be merged into a float tuple

What do you think about geopy for that @yezz123 ? It seems like a reasonable lib for doing that, or should we keep it simpler by coding it ouselves ?

best to keep it simple if possible, see #74.

Thanks @samuelcolvin, I'll check that.

commented

To give some more meat on the bone here:

  • Latitude is Northing from -90.0 to 90.0 degree.
  • Longitude is Easting from -180.0 to 180.0 degree. Definitions from 0.0 to 360.0 degree have to be normalized to -180. to 180 degree.
  • Latitude degree

  • Longitude degree

Could also be merged into a float tuple

If precision is important, I'd recommend using Decimal instead of float.

This speaks to the concern:
https://docs.python.org/3/tutorial/floatingpoint.html

With the example:

>>> 0.1
0.1000000000000000055511151231257827021181583404541015625
commented

A float is absolutely sufficient, there is no need to go to Decimals

See https://xkcd.com/2170/