<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi,</p>
<p>I was not expecting that answer and less to hear about
calculations on the sphere when we are talking about geodesy!.<br>
</p>
<p>The comparison between the spheroidal (local sphere) and
spherical intersection has already been made in the article. We
did it because some software uses this approach. It is important
for us to check each software methodology in order to be able to
rigorously compare the results.<br>
</p>
<p>The spherical method is very easy and trivial because it is just
using spherical trigonometry but the errors commited and very
large as you can check in our paper, so please keep it without
exposing this functionality to the end user because it is a very
rude approach, and if so the end user must be warned about that.
By the way, the name of the source code in postgis about geodetic
calculations (lwgeodetic) could be confusing because geodetic
coordinates use a spheroid not a sphere, and geodetic calculations
should be done using geodesics lines.<br>
</p>
<p>You talked about 1% of distance errors saying that its *not that
wrong*. Umm...do not know how to answer that...I mean 1% its
incredible wrong, even 1 per thousands its not ok for many tasks.<br>
</p>
<p>Maybe 1% could be ok for those users who use postgis to make
thematic maps in a small scales but anything else. <br>
</p>
<p>I am referring to the maps listed in annexes 1 and 2 of inspire
in Europe, or similar in other countries: cadastral maps,
transport networks, etc. on a large scale, so it means that the
error tolerance in only a few centimeters but the distances of the
segments can be long, so no spherical method can be used, or even
a local projected transformation, at least without knowing the
error comitted (error that you do not know with postgis or other
app right now) in advance.<br>
</p>
<p>I agree with you about that to build a full set of spatial
operators working on the spheroid is a much more complicated task
that just an intersection of geodesics, but with the two proposed
algorithm (geodesic intersection and minimun distance from a point
to a geodesic) you can already do many things, even just
involving linear layers. Do you really need to build a full
topology geodetic library in order to incorporate in postgis the
two funtions I am talking about?<br>
</p>
<p>So, this methodoly give you:</p>
<p>1.- Exact solution<br>
</p>
<p>2.- Assesment of the commited errors of other methods (spherical,
projected CRS, etc.). <br>
</p>
<p>3.- Working with the full globe, no matter the distance for the
precision.</p>
<p>Cheers</p>
<p>José<br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">El 28/07/2021 a las 18:54, Paul Ramsey
escribió:<br>
</div>
<blockquote type="cite"
cite="mid:CACowWR3_UeTtDAH5RX7DAnKFiav0vyRuG7q5L=pGYpRaDm=SMQ@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div>This is very interesting, but from a practical point of
view the problems around doing intersections on the spheroid
are not to do with the difficulty of calculating spheroidal
intersection points, but the difficulty in programming things
that are relatively simple in cartesian (R2) space in
spherical space (S2), like "is this point in this ring",
because the question of "what does this ring enclose" is quite
different in S2 than in R2. IE, the complexity of the problem
does not reside in the spheroidal geometry but in the
spherical topology. Which is not to say that it cannot be
done, Google S2 has done a number of constructive geometry
functions in spherical space, but it's not just a matter of
getting the right intersection points.<br>
</div>
<div><br>
</div>
<div>I would be interested in direct comparisons between
spheroidal and spherical intersection, rather than comparisons
with "whatever the heck these tools use under the covers",
which your survey shows is "quite a wide variety of
approaches". <br>
</div>
<div><br>
</div>
<div>Unfortunately although PostGIS has spherical intersection
internally (hilariously, I calculate it here [1] but never
even let it out of the function) it is not exposed to the end
user. You could use Google S2 [2] to generate spherical
intersection points though, and compare those to spheroidal. <br>
</div>
<div><br>
</div>
<div>The reason I ask is because comparison of spherical and
spheroidal *distances* never yield particularly large
differences, always under 1%. Now, spherical distances are not
*right*, but they are also *not that wrong* which is
presumably why tools like S2 have eschewed finding spheroidal
intersections. Under the covers you'll find that the PostGIS
distance functions use spherical calculations to find the two
points that are closest between two geometries, and only then
calculate the spheroidal distance between those points.</div>
<div><br>
</div>
<div>Thanks for sharing your research,</div>
<div>Paul<br>
</div>
<div><br>
</div>
<div>[1] <a
href="https://github.com/postgis/postgis/blob/main/liblwgeom/lwgeodetic.c#L3596"
moz-do-not-send="true">https://github.com/postgis/postgis/blob/main/liblwgeom/lwgeodetic.c#L3596</a><br>
[2] <a href="http://s2geometry.io/" moz-do-not-send="true">http://s2geometry.io/</a></div>
<div><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Tue, Jul 27, 2021 at 9:34
AM José Carlos Martínez <<a
href="mailto:jomarlla@cgf.upv.es" moz-do-not-send="true">jomarlla@cgf.upv.es</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi
list,<br>
<br>
I want to share our last research about gemetric operations on
the <br>
spheroid [1]<br>
<br>
Considering two segments defined by 2 points each one over the
spheroid.<br>
We want to get the intersection point defined by these two
segments.<br>
<br>
Several points to note:<br>
1.- We could not find any software (Oracle Spatial, ArcGIS,
PostGIS, <br>
Google Apis) that performs this calculation on the ellipsoid:
some use <br>
projected CRS, others just use a local sphere.<br>
2.- The error comitted by these software is unknown. And I go
further, <br>
these unknown errors could be greater than the cartographic
precision of <br>
my geo data? If so, all my geo spatial analysis could be
wrong.<br>
3.- We designed a new algorithm of fast convergence working on
the <br>
spheroid. We can get the exact intersection point, therefore
we can <br>
asses the error from the current software solutions.<br>
4.- Example: working with segments around 50km length, the
error is <br>
around 3 meters (PostGIS, ArcGIS). Table 4 from paper [2]
shows the <br>
large error commited by Oracle Spatial, ArcGIS, and even
PostGIS with <br>
local projected CRS (st_intersection with geography).<br>
5.- This proposed algorithm is implemented as a test in
PostGIS, Java <br>
and Maxima.<br>
<br>
<br>
Finally, mention that, in a normal computer, about 20,000
intersections <br>
per second have been obtained. Perhaps, now is the time to
migrate <br>
certain geospatial libraries such as JTS (GEOS), GDAL, etc. so
that they <br>
carry out the calculations in full on the ellipsoid and thus
be able to <br>
forget about the projected CRS, and leave them purely for
aesthetic <br>
purposes.<br>
<br>
I will be proud of helping the PostGIS or the JTS team to
incorporate <br>
these geometric operations on the ellipsoid (could be the
first spatial <br>
BDD or geospatial library to do that).<br>
<br>
<br>
Cheers,<br>
<br>
José<br>
<br>
<br>
All the information, source code, etc. here.<br>
[1] <br>
<a
href="https://cartosig.webs.upv.es/2021/07/27/geodesic-intersection-proposed-algorithm-and-error-assessment-of-current-software/"
rel="noreferrer" target="_blank" moz-do-not-send="true">https://cartosig.webs.upv.es/2021/07/27/geodesic-intersection-proposed-algorithm-and-error-assessment-of-current-software/</a><br>
<br>
[2] <a href="https://www.mdpi.com/2076-3417/11/11/5129"
rel="noreferrer" target="_blank" moz-do-not-send="true">https://www.mdpi.com/2076-3417/11/11/5129</a><br>
<br>
Martínez-Llario JC, Baselga S, Coll E. Accurate Algorithms for
Spatial <br>
Operations on the Spheroid in a Spatial Database Management
System. <br>
Applied Sciences. 2021; 11(11):5129. <a
href="https://doi.org/10.3390/app11115129" rel="noreferrer"
target="_blank" moz-do-not-send="true">https://doi.org/10.3390/app11115129</a><br>
<br>
[3] <a
href="https://link.springer.com/article/10.1007/s11200-017-1020-z"
rel="noreferrer" target="_blank" moz-do-not-send="true">https://link.springer.com/article/10.1007/s11200-017-1020-z</a><br>
<br>
Baselga, S., Martínez-Llario, J.C. Intersection and
point-to-line <br>
solutions for geodesics on the ellipsoid. Stud Geophys Geod
62, 353–363 <br>
(2018). <a href="https://doi.org/10.1007/s11200-017-1020-z"
rel="noreferrer" target="_blank" moz-do-not-send="true">https://doi.org/10.1007/s11200-017-1020-z</a><br>
<br>
[4] <a
href="https://github.com/jomarlla/geodesicSpatialOperators"
rel="noreferrer" target="_blank" moz-do-not-send="true">https://github.com/jomarlla/geodesicSpatialOperators</a><br>
<br>
<br>
-- <br>
-------------------------------<br>
José Carlos Martínez Llario<br>
<a href="http://www.upv.es/ficha-personal/jomarlla"
rel="noreferrer" target="_blank" moz-do-not-send="true">http://www.upv.es/ficha-personal/jomarlla</a><br>
<a href="https://cartosig.webs.upv.es" rel="noreferrer"
target="_blank" moz-do-not-send="true">https://cartosig.webs.upv.es</a><br>
Producción Cartográfica y SIG.<br>
Dpto. Ingeniería Cartográfica.<br>
Univ. Politécnica de Valencia.<br>
-------------------------------<br>
<br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank"
moz-do-not-send="true">postgis-users@lists.osgeo.org</a><br>
<a
href="https://lists.osgeo.org/mailman/listinfo/postgis-users"
rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/postgis-users</a><br>
</blockquote>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/postgis-users">https://lists.osgeo.org/mailman/listinfo/postgis-users</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
-------------------------------
José Carlos Martínez Llario
<a class="moz-txt-link-freetext" href="http://www.upv.es/ficha-personal/jomarlla">http://www.upv.es/ficha-personal/jomarlla</a>
<a class="moz-txt-link-freetext" href="https://cartosig.webs.upv.es">https://cartosig.webs.upv.es</a>
Producción Cartográfica y SIG.
Dpto. Ingeniería Cartográfica.
Univ. Politécnica de Valencia.
-------------------------------</pre>
</body>
</html>