Revision: 4664 http://sourceforge.net/p/jump-pilot/code/4664 Author: bertazza Date: 2015-12-23 23:13:38 +0000 (Wed, 23 Dec 2015) Log Message: ----------- Fixed broken 4663 commit
Modified Paths: -------------- core/trunk/ChangeLog core/trunk/src/com/vividsolutions/wms/Parser.java Modified: core/trunk/ChangeLog =================================================================== --- core/trunk/ChangeLog 2015-12-23 16:26:41 UTC (rev 4663) +++ core/trunk/ChangeLog 2015-12-23 23:13:38 UTC (rev 4664) @@ -3,6 +3,9 @@ # 2. make sure that lines break at 80 chars for constricted display situations #<-------------------------------- 80 chars ----------------------------------># +2015-12-24 bertazza + * Fixed broken 4663 commit + 2015-12-23 bertazza * Info feature tool: added a pane to show WMS info. Modified: core/trunk/src/com/vividsolutions/wms/Parser.java =================================================================== --- core/trunk/src/com/vividsolutions/wms/Parser.java 2015-12-23 16:26:41 UTC (rev 4663) +++ core/trunk/src/com/vividsolutions/wms/Parser.java 2015-12-23 23:13:38 UTC (rev 4664) @@ -62,6 +62,7 @@ import com.vividsolutions.jump.I18N; import com.vividsolutions.wms.util.XMLTools; +import java.util.List; /** @@ -108,6 +109,7 @@ LinkedList<String> srsList = new LinkedList<String>(); LinkedList<MapLayer> subLayers = new LinkedList<MapLayer>(); BoundingBox bbox = null; + List<MapStyle> styles = new ArrayList<MapStyle>(); // I think, bbox is LatLonBoundingBox. // I need a new variable for BoundingBox. @@ -116,6 +118,7 @@ // BoundingBox boundingBox = null; ArrayList<BoundingBox> boundingBoxList = new ArrayList<BoundingBox> ( ); + NodeList nl = layerNode.getChildNodes(); for( int i = 0; i< nl.getLength(); i++ ) { @@ -154,8 +157,46 @@ } else if( n.getNodeName().equals( "Layer" ) ) { subLayers.add( wmsLayerFromNode( n ) ); - } + } else if (n.getNodeName().equals("Style")) { //$NON-NLS-1$ + String styleName = ""; //$NON-NLS-1$ + String titleName = ""; //$NON-NLS-1$ + String legendFormat = ""; //$NON-NLS-1$ + String url = ""; //$NON-NLS-1$ + int h=0,w=0; + NodeList nodeStyle = n.getChildNodes(); + for( int k = 0; k < nodeStyle.getLength(); k++ ) { + Node n1 = nodeStyle.item(k); + if (n1.getNodeName().equals("Name")) { //$NON-NLS-1$ + styleName = ((CharacterData) n1.getFirstChild()).getData(); + } else if (n1.getNodeName().equals("Title") & n1.hasChildNodes()) { //$NON-NLS-1$ + titleName = ((CharacterData) n1.getFirstChild()).getData(); + } else if (n1.getNodeName().equals("LegendURL")) { //$NON-NLS-1$ + try { + h=Integer.parseInt(n1.getAttributes().getNamedItem("height").getNodeValue()); + w=Integer.parseInt(n1.getAttributes().getNamedItem("width").getNodeValue()); + } + catch (Exception e) { + e.printStackTrace(); + throw new Exception(e.toString()); + } + NodeList nodelegend = n1.getChildNodes(); + for( int k1 = 0; k1 < nodelegend.getLength(); k1++ ) { + Node n2 = nodelegend.item(k1); + if (n2.getNodeName().equals("Format")) { //$NON-NLS-1$ + legendFormat = + ((CharacterData) n2.getFirstChild()).getData(); + } else if (n2.getNodeName().equals("OnlineResource")) { //$NON-NLS-1$ + url = + n2.getAttributes() + .getNamedItem("xlink:href").getNodeValue(); //$NON-NLS-1$ + } + } + + } + } + styles.add(new MapStyle(styleName, titleName, url, legendFormat,w,h)); } + } } catch( Exception e ) { e.printStackTrace(); LOG.error( "Exception caught in wmsLayerFromNode(): " + e.toString() ); @@ -164,7 +205,7 @@ // call the new constructor with boundingBoxList in MapLayer [uwe dalluege] return new MapLayer - ( name, title, srsList, subLayers, bbox, boundingBoxList ); + ( name, title, srsList, subLayers, bbox, boundingBoxList, styles ); } /** @@ -269,9 +310,9 @@ } // get the top layer - topLayer = wmsLayerFromNode( XMLTools.simpleXPath( doc, "WMT_MS_Capabilities/Capability/Layer" ) ); + topLayer = wmsLayerFromNode( XMLTools.simpleXPath( doc, "WMT_MS_Capabilities/Capability/Layer" ) ); - return new Capabilities( service, title, topLayer, formatList ); + return new Capabilities( service, title, topLayer, formatList, getInfoFormats(doc, "WMT_MS_Capabilities") ); } //UT TODO move this into a common method ( @@ -357,7 +398,29 @@ // get the top layer topLayer = wmsLayerFromNode( XMLTools.simpleXPath( doc, "WMT_MS_Capabilities/Capability/Layer" ) ); - return new Capabilities( service, title, topLayer, formatList, getMapURL, getFeatureInfoURL ); + return new Capabilities( service, title, topLayer, formatList, getInfoFormats(doc, "WMT_MS_Capabilities"), getMapURL, getFeatureInfoURL ); } + protected LinkedList<String> getInfoFormats(Document doc, String rootPath) { + + // get the supported infoFormats + final Node formatNode = XMLTools.simpleXPath(doc, rootPath + "/Capability/Request/GetMap"); + NodeList nl = formatNode.getChildNodes(); + + final Node infoFormatNode = XMLTools.simpleXPath(doc, "WMT_MS_Capabilities/Capability/Request/GetFeatureInfo"); + LinkedList<String> infoFormatList = new LinkedList<String>(); + if (infoFormatNode != null) { + nl = infoFormatNode.getChildNodes(); + for (int i = 0; i < nl.getLength(); i++) { + Node n = nl.item(i); + if (n.getNodeType() == Node.ELEMENT_NODE && "Format".equals(n.getNodeName())) { + infoFormatList.add(n.getFirstChild().getNodeValue()); + } + } + } + + return infoFormatList; + + } + } ------------------------------------------------------------------------------ _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel