ProjUtils.getSRSInfoFromLayerStyleOrSource(layer) . It should implemented
also for WMS and WFS layerables

Il 29/Giu/2017 20:02, "Michaël Michaud" <m.michael.mich...@orange.fr> ha
scritto:

Hi Jukka,

Sorry, for the misleading instruction, I dont't know why I thought you was
working on a WMSLayer.

Peppe's answer was just right. Maybe you just needed to import the
following classes. Try this :

import org.openjump.core.ccordsys.utils.ProjUtils;
import org.openjump.core.ccordsys.utils.SRSInfo;

lyr = wc.getLayerNamePanel().getSelectedLayers()[0];
SRSInfo info = ProjUtils.getSRSInfoFromLayerStyleOrSource(lyr);
print(info.getRegistry());
print(info.getCode());
Michaël



Le 29/06/2017 à 11:40, Rahkonen Jukka (MML) a écrit :

Hi Michaël,



Some little issue:

-          lyr = wc.layerNamePanel.selectedLayerables.get(0); seems to work
and “lyr” contains now the name of the selected layer “New”

-          lyr.getSRS() throws an error:



Sourced file: lib\ext\BeanTools\Cut_MBtiles.bsh : Error in method
invocation: Method getSRS() not found in class'com.vividsolutions.jump.
workbench.model.Layer'





-Jukka Rahkonen-





*Lähettäjä:* Michaël Michaud [mailto:m.michael.mich...@orange.fr
<m.michael.mich...@orange.fr>]
*Lähetetty:* 28. kesäkuuta 2017 14:45
*Vastaanottaja:* jump-pilot-devel@lists.sourceforge.net
*Aihe:* Re: [JPP-Devel] How to get layer SRS with a BeanShell script?



Hi Jukka,

I think you can't use wc.getLayerNamePanel().getSelectedLayers()[0]
because it is an old method returning only vector layers

Instead, you can use wc.getLayerNamePanel().getSelectedLayerables().get(0)
If you keep a reference to the layer :
*lyr = wc.layerNamePanel.selectedLayerables.get(0)*

then you can get the SRS from the layer this way :
*lyr.getSRS()*

Hope that helps,

Michaël

Le 27/06/2017 à 15:56, Rahkonen Jukka (MML) a écrit :

Hi,



If layers can know their SRS I wonder how could I read the value with
BeanShell.



For example what to do for edding the EPSG code to this snippet that writes
upper left – lower right coordinates for a GDAL command



htmlFrame.setTitle("BBOX Output");

fc = wc.getLayerNamePanel().getSelectedLayers()[0].
getFeatureCollectionWrapper();

int j=1;

for (Iterator i = fc.getFeatures().iterator(); i.hasNext();) {

Feature feature = (Feature) i.next();

Geometry geometry = feature.getGeometry();

Envelope env = geometry.getEnvelopeInternal();

htmlFrame.addText("gdal_translate "

+"-of MBTiles "

+"-projwin "

+env.getMinX()+" "

+env.getMaxY()+" "

+env.getMaxX()+" "

+env.getMinY()+" "

+"-projwin_srs epsg:"

+ WHAT?





-Jukka Rahkonen-




------------------------------------------------------------------------------

Check out the vibrant tech community on one of the world's most

engaging tech sites, Slashdot.org! http://sdm.link/slashdot




_______________________________________________

Jump-pilot-devel mailing list

Jump-pilot-devel@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot



_______________________________________________
Jump-pilot-devel mailing
listJump-pilot-devel@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/jump-pilot-devel



------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to