opengeospatial / geoapi

GeoAPI provides a set of interfaces in programming languages (currently Java and Python) for geospatial applications. The GeoAPI interfaces closely follow OGC specifications, adaptated to match the expectations of programmers.
http://www.geoapi.org
Apache License 2.0
118 stars 37 forks source link

Replace Integer/Double by BigInteger/BigDecimal in metadata #87

Open desruisseaux opened 1 year ago

desruisseaux commented 1 year ago

The ISO 19115-1 standard defines each attribute as optional, mandatory or conditional. The GeoAPI interfaces in the org.opengis.metadata packages reflects the ISO specification by allowing values to be null. Since Java primitive types such as int or double cannot be null, GeoAPI workarounds this limitation by using their wrapper classes instead, which are java.lang.Integer and java.lang.Double respectively. But those numeric values could have been made more flexible by using BigInteger and BigDecimal instead. It would avoid limitations in the magnitude of the number and in precision. It would also allows floating point values to better capture the precision intended by the data producer, which is usually in base 10 with a fixed number of fraction digits (that number can be specified to BigDecimal).. BigInteger and BigDecimal are the types used by default by some tools that generate Java code from XML schemas.

This proposal to replace java.lang.Integer and java.lang.Double by java.math.BigInteger and java.math.BigDecimal is for metadata only, because performance is usually not an issue in metadata (contrarily to referencing, features or coverages) and wrapper classes were already used in metadata anyway (we are not proposing to replace primitive type usages).

desruisseaux commented 3 months ago

Duplicates #46. A possible compromise may be BigInteger for counts, Quantity<?> for real numbers with units of measurement, Number for the rest.