@@ -75,20 +75,19 @@ protected Item(org.w3c.dom.Node node) {
|
75 | 75 |
|
76 | 76 |
|
77 | 77 | //Parse Location Information (GeoRSS)
|
78 |
| -if (nodeName.equals("where") || nodeName.equals("georss:where") || |
79 |
| -nodeName.equals("point") || nodeName.equals("georss:point") || |
80 |
| -nodeName.equals("line") || nodeName.equals("georss:line") || |
81 |
| -nodeName.equals("polygon") || nodeName.equals("georss:polygon") || |
82 |
| -nodeName.equals("box") || nodeName.equals("georss:box")){ |
83 |
| -try{ |
84 |
| -//geometry = new Parser(nodeValue).getGeometry(); |
85 |
| -Class classToLoad = Class.forName("javaxt.geospatial.coordinate.Parser");//, true, child); |
86 |
| -java.lang.reflect.Constructor constructor = classToLoad.getDeclaredConstructor(new Class[] {String.class}); |
87 |
| -java.lang.reflect.Method method = classToLoad.getDeclaredMethod ("getGeometry"); |
88 |
| -Object instance = constructor.newInstance(); |
89 |
| -geometry = method.invoke(instance); |
| 78 | +if (nodeName.equals("where") || nodeName.equals("georss:where")){ |
| 79 | +NodeList nodes = node.getChildNodes(); |
| 80 | +for (int j=0; j<nodes.getLength(); j++){ |
| 81 | +if (nodes.item(j).getNodeType()==1){ |
| 82 | +if (isGeometryNode(nodes.item(j).getNodeName().toLowerCase())){ |
| 83 | +geometry = getGeometry(DOM.getNodeValue(nodes.item(j)).trim()); |
| 84 | +if (geometry!=null) break; |
| 85 | +} |
| 86 | +} |
90 | 87 | }
|
91 |
| -catch(Exception e){} |
| 88 | +} |
| 89 | +if (isGeometryNode(nodeName)){ |
| 90 | +geometry = getGeometry(nodeValue); |
92 | 91 | }
|
93 | 92 |
|
94 | 93 |
|
@@ -99,6 +98,39 @@ protected Item(org.w3c.dom.Node node) {
|
99 | 98 | }
|
100 | 99 |
|
101 | 100 |
|
| 101 | +protected static boolean isGeometryNode(String nodeName){ |
| 102 | +String namespace = null; |
| 103 | +if (nodeName.contains(":")){ |
| 104 | +namespace = nodeName.substring(0, nodeName.lastIndexOf(":")); |
| 105 | +nodeName = nodeName.substring(nodeName.lastIndexOf(":")+1); |
| 106 | +} |
| 107 | +if (namespace==null || namespace.equals("gml") || namespace.equals("georss")) |
| 108 | +return |
| 109 | +(nodeName.equals("point") || nodeName.equals("multipoint") || |
| 110 | +nodeName.equals("line") || |
| 111 | +nodeName.equals("linestring") || nodeName.equals("multilinestring") || |
| 112 | +nodeName.equals("polygon") || nodeName.equals("multipolygon") || |
| 113 | +nodeName.equals("box") || nodeName.equals("envelope")); |
| 114 | +else return false; |
| 115 | +} |
| 116 | + |
| 117 | + |
| 118 | +protected static Object getGeometry(String nodeValue){ |
| 119 | +try{ |
| 120 | +//geometry = new Parser(nodeValue).getGeometry(); |
| 121 | +Class classToLoad = Class.forName("javaxt.geospatial.coordinate.Parser"); |
| 122 | +java.lang.reflect.Constructor constructor = classToLoad.getDeclaredConstructor(new Class[] {String.class}); |
| 123 | +java.lang.reflect.Method method = classToLoad.getDeclaredMethod("getGeometry"); |
| 124 | +Object instance = constructor.newInstance(new Object[] { nodeValue }); |
| 125 | +return method.invoke(instance); |
| 126 | +} |
| 127 | +catch(Exception e){ |
| 128 | +//e.printStackTrace(); |
| 129 | +return null; |
| 130 | +} |
| 131 | +} |
| 132 | + |
| 133 | + |
102 | 134 |
|
103 | 135 |
|
104 | 136 | public String getTitle(){ return title; }
|
|
0 commit comments