<div dir="ltr"><div>Even:<br><br>> No need for a complicated thing like a JNI bridge, but someone has to code it in GDAL. All the basic functionnality is there. Just needs to be put together.</div><div><br>The main reason I suggested geotools is that one only needs to write only a few trivial lines of code to get the correct EPSG identifier for a given WKT string -so in theory, most of the work would be the JNI bindings themselves. I provided a working sample below that would autodetect the example SRID correctly as 2277. The only downside I have encountered so far is the slow search speed -but that could be mitigated by caching strings that have already been mapped. I wonder if there is a repository somewhere that has a large number of arbitrary WKT strings from "the wild" mapped to the correct EPSG code -would be useful for getting at least a rough sense of accuracy for any given wkt -> epsg conversion solution.<br></div><div><br>Andrea:<br><br><div style="font-size:12.8px">> <a href="http://prj2epsg.org/" target="_blank">prj2epsg.org</a> uses that (a much older version of it actually) along with pure and simple full text search matches.<br><br>I was actually the person who asked them to put up that repo up on github because I initially wanted to try their codebase for wkt -> epsg conversion, thinking that it would be superior (and faster) than raw geotools -but was astounded when I saw the wrong projection come back for the WKT string. It might be worth submitting a pull request with updated dependencies -since prj2epsg is typically referenced in various open source GIS documentation and on gis.stackexchange as the simplest way to upload a .prj file and get back the correct EPSG code. </div></div><div><br></div><div>import org.geotools.factory.Hints;</div><div>import org.geotools.referencing.CRS;</div><div>import org.opengis.referencing.FactoryException;</div><div><br></div><div>public class BasicWktParser {</div><div><br></div><div>  static {</div><div>    System.setProperty("org.geotools.referencing.forceXY", "true");</div><div>    Hints.putSystemDefault(Hints.FORCE_AXIS_ORDER_HONORING, "http");</div><div>    Hints.putSystemDefault(Hints.COMPARISON_TOLERANCE, 1e-9);</div><div>  }</div><div><br></div><div>  public static void main(String[] args) throws FactoryException {</div><div>    String identifier = CRS.lookupIdentifier(CRS.parseWKT(args[0]), true);</div><div>    System.out.println(identifier);</div><div>  }</div><div><br></div><div>}<br><br> relevant build.gradle declarations:<br><br><div>dependencies {</div><div>    compile (group: 'org.geotools', name: 'gt-epsg-hsql', version: '17.2') {</div><div>        exclude module: 'jai_core'</div><div>    }</div><div>    compile (group: 'org.geotools', name: 'gt-epsg-extension', version: '17.2') {</div><div>        exclude module: 'jai_core'</div><div>    }</div><div>}</div><div><br></div><div>repositories {</div><div><br></div><div>        mavenCentral()</div><div><br></div><div>        maven {</div><div>            url "<a href="http://repo.boundlessgeo.com/main/">http://repo.boundlessgeo.com/main/</a>"</div><div>        }</div><div><br></div><div>        maven {</div><div>            url "<a href="http://download.osgeo.org/webdav/geotools/">http://download.osgeo.org/webdav/geotools/</a>"</div><div>        }</div><div>}</div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 23, 2017 at 8:00 AM, Andrea Aime <span dir="ltr"><<a href="mailto:andrea.aime@geo-solutions.it" target="_blank">andrea.aime@geo-solutions.it</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div>
<div dir="ltr">Hi Even,
<div>just a quick note about GeoTools and <a href="http://prj2epsg.org" target="_blank">http://prj2epsg.org</a></div>
<div><br>
</div>
<div>In terms of matching via GeoTools, we have spent quite some time building tables of aliases and </div>
<div>some lax equivalence rules, think DMS is same a deegree, some tolerance on the parameter</div>
<div>values, and so on.</div>
<div><br>
</div>
<div><a href="http://prj2epsg.org" target="_blank">prj2epsg.org</a> uses that (a much older version of it actually) along with pure and simple full text search matches.</div>
<div><br>
</div>
<div>It basically extracts a set of keywords from the WKT and searches against a similar database</div>
<div>built by indexing all of the EPSG database contents. This is actually what happens when you put</div>
<div>in that prj file, the result you're pointing to is the 3rd match.</div>
<div>If you input instead something that is actually equivalent, then you'll get a single result.</div>
<div><br>
</div>
<div>Looks like Boundless made the old code for the site publicly available on github really recently:</div>
<div><a href="https://github.com/boundlessgeo/prj2epsg" target="_blank">https://github.com/<wbr>boundlessgeo/prj2epsg</a><br>
</div>
<div>Still using a GeoTools 2.6.6, oh dear! :-)</div>
<div><br>
</div>
<div>Cheers</div>
<div>Andrea</div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote"><div><div class="h5">On Sat, Sep 23, 2017 at 11:19 AM, Even Rouault <span dir="ltr">
<<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
<u></u>
<div style="font-family:'monospace';font-size:9pt;font-weight:400;font-style:normal">
<span>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
> I've had this issue for years, but concede I might be missing something. Is</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
> there anything that can remedy this issue utilizing existing functionality?</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
 </p>
</span>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
No need for a complicated thing like a JNI bridge, but someone has to code it in GDAL. All the basic functionnality is there. Just needs to be put together. A basic approach would be to iterate over the EPSG codes from the gcs.csv and pcs.csv files, use importFromEPSG()
 and compare the resulting WKT with the user WKT. Some fuzzing would be needed to be robust to slight naming variations, etc. This was actually an idea for a GSoc project, but anyone is free to pick it up and bring his/her contribution.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
 </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
In the .prj you pointed, prj2epsg first suggestion, EPSG:32139, is actually completely inappropriate given it uses meter as linear unit, whereas the .prj uses foot_us. EPSG:2277 looks to be the exact match. And another interesting thing is that the .prj has
 Standard_Parallel_1 = 30.11666666666667 and Standard_Parallel_2 = 31.88333333333333. Whereas EPSG:2277 has them in the reverse order. Which is equivalent mathematically, but a matcher should be aware of that equivalence. So not completely a trivial task.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
 </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
Even</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
 </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
-- </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
Spatialys - Geospatial professional services</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
<a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a></p>
</div>
<br></div></div>
______________________________<wbr>_________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailma<wbr>n/listinfo/gdal-dev</a><br>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div class="m_3340940515250240203gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr"><span>
<p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><font size="2">Regards,</font></span></p>
<p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><font size="2">Andrea Aime</font></span></p>
<p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><font size="2"><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap">==</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><br>
</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap">GeoServer Professional Services from the experts! Visit
<a href="http://goo.gl/it488V" target="_blank">http://goo.gl/it488V</a> for more information.</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><br>
</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap">==</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><br>
</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><br>
</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap">Ing. Andrea Aime
</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><br>
</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap">@geowolf</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><br>
</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap">Technical Lead</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><br>
</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><br>
</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap">GeoSolutions S.A.S.</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><br>
</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><a href="https://maps.google.com/?q=Via+di+Montramito+3/A+%0D+55054+%C2%A0Massarosa&entry=gmail&source=g">Via di Montramito 3/A</a></span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><br>
</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><a href="https://maps.google.com/?q=Via+di+Montramito+3/A+%0D+55054+%C2%A0Massarosa&entry=gmail&source=g">55054 </a> <a href="https://maps.google.com/?q=Via+di+Montramito+3/A+%0D+55054+%C2%A0Massarosa&entry=gmail&source=g">Massarosa</a> (LU)</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><br>
</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap">phone: <a href="tel:+39%200584%20962313" value="+390584962313" target="_blank">+39 0584 962313</a></span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><br>
</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap">fax: <a href="tel:+39%200584%20166%200272" value="+3905841660272" target="_blank">+39 0584 1660272</a></span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><br>
</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap">mob: <a href="tel:+39%20339%20884%204549" value="+393398844549" target="_blank">+39  339 8844549</a></span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><br>
</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><br>
</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><a href="http://www.geo-solutions.it" target="_blank">http://www.geo-solutions.it</a></span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><br>
</span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><a href="http://twitter.com/geosolutions_it" target="_blank">http://twitter.com/<wbr>geosolutions_it</a></span><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><br>
<br>
</span></font></p>
<p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><font size="2">AVVERTENZE AI SENSI DEL D.Lgs. 196/2003</font></span></p>
<p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><font size="2">Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i
 sono da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente
 di darcene notizia via e-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse,
 costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.</font></span></p>
<p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><font size="2"></font></span></p>
<p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><font size="2">The information in this message and/or attachments, is intended solely for the attention and use
 of the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction,
 copying, distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail
 and delete the information in this message that has been received in error. The sender does not give any warranty or accept liability as the content, accuracy or completeness of sent messages and accepts no responsibility  for changes made after they were
 sent or for other risks which arise as a result of e-mail transmission, viruses, etc.</font></span></p>
<div><span style="font-size:11pt;font-family:Arial;vertical-align:baseline;white-space:pre-wrap"><br>
</span></div>
</span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

</blockquote></div><br></div>