Hi Mark,
it's actually been longer than 10 years, but the Git history history is 10
years long.
Checking the GeoTools history, the 2.x branch, which is around 20 years
old, was already using -1 (grep for it in the sources):
https://svn.osgeo.org/geotools/branches/2.0.x/gt/plugin/postgis/src/org/geotools/data/postgis/PostgisDataStore.java

I was worried that EPSG had 0 in their reserved code range, but it turns
out it's not, from the guidance note:
" Now codes are assigned sequentially and no meaning should be interpreted.
Codes are within the
range 1024 to 32767 inclusive.
<other text skipped for brevity>
Users who wish to augment the EPSG data with their own information should
utilise codes greater than 32767."

Seems like 0 is fair game. However, before switching to it, I guess every
other database should be checked and
verify that zero has no particular meaning for them. As an alternative, you
can move the "unknown SRID" value
to a SQL dialect provider method, default it to -1, and override as needed
in subclasses.

Cheers
Andrea



On Fri, Nov 6, 2020 at 12:37 PM Mark Prins <mc.pr...@gmail.com> wrote:

> Hi,
> This question rose while upgrading the MySQL module to version 8 where I
> ran into the database throwing a "MysqlDataTruncation" exception with
> message "Data truncation: SRID value is out of range in
> 'st_geomfromtext'" when passing -1 as the SRID value when one of the
> tests inserted a geometry without SRID.
>
> I traced this back to
> JDBCDataStore#getDescriptorSRID(AttributeDescriptor) defaulting to -1 as
> the unknown value:
>
> https://github.com/geotools/geotools/blob/821d9add2f8de1f6649601dc4a67ccd9c64f1719/modules/library/jdbc/src/main/java/org/geotools/jdbc/JDBCDataStore.java#L4291-L4302
>
> There's actually a default to -1 for srid in setPreparedFilterValues()
> as well.
>
> I found this note on the PostGIS ST_SRID page:
> https://postgis.net/docs/RT_ST_SRID.html
>
>     "From PostGIS 2.0+ the srid of a non-georeferenced raster/geometry
> is 0 instead of the prior -1."
>
> Which might explain why (and it's been like that for at least 10 years),
> but if postgis stopped using -1 maybe we should too?
> (postgis seems lenient to using -1 as a srid)
>
> Mark
>
>
> _______________________________________________
> GeoTools-Devel mailing list
> GeoTools-Devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-devel
>


-- 

Regards, Andrea Aime

== GeoServer Professional Services from the experts! Visit
http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf
Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa
(LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549
http://www.geo-solutions.it http://twitter.com/geosolutions_it
------------------------------------------------------- *Con riferimento
alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 -
Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni
circostanza inerente alla presente email (il suo contenuto, gli eventuali
allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i
destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per
errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le
sarei comunque grato se potesse darmene notizia. This email is intended
only for the person or entity to which it is addressed and may contain
information that is privileged, confidential or otherwise protected from
disclosure. We remind that - as provided by European Regulation 2016/679
“GDPR” - copying, dissemination or use of this e-mail or the information
herein by anyone other than the intended recipient is prohibited. If you
have received this email by mistake, please notify us immediately by
telephone or e-mail.*
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to