Revision 103

View differences:

org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.extension/src/main/java/org/gvsig/gazetteer/loaders/FeatureLoader.java
143 143
		IProjection projection = activeView.getProjection();
144 144
		ViewPort viewPort = activeView.getMapControl().getViewPort();
145 145
		MapContext mapContext = activeView.getMapControl().getMapContext();
146
		Point2D point = getReprojectedPoint(feature.getCoordinates());
146
		Point point = getReprojectedPoint((feature.getCoordinates()));
147
//        Point point = feature.getCoordinates();
147 148

  
148 149
		if (viewPort.getAdjustedEnvelope() != null){
149 150
			Toolkit kit = Toolkit.getDefaultToolkit();
......
200 201
			lyr.clearAllGraphics();
201 202
		}
202 203

  
203
		if (isMarkedPlaceClicked){
204
			int pointSymbol = lyr.addSymbol(getSymbol());
205
			int textSymbol = lyr.addSymbol(getTextSymbol(feature.getName()));
204
        if (isMarkedPlaceClicked) {
205
            int pointSymbol = lyr.addSymbol(getSymbol());
206
            int textSymbol = lyr.addSymbol(getTextSymbol(feature.getName()));
206 207

  
208
            Point point = feature.getCoordinates();
209
            lyr.setCoordTrans(getCoordTrans());
210
            lyr.addGraphic("gazetteer", point, pointSymbol, null);
211
            lyr.addGraphic("gazetteer", point, textSymbol, feature.getName());
212
            DeleteSearchesExtension.setVisible();
213
            PluginServices.getMainFrame().enableControls();
214
        }
207 215

  
208
			Point2D point2d = getReprojectedPoint(feature.getCoordinates());
209
			feature.setCoordinates(point2d);
210
			Point point;
211
			try {
212
				point = geometryManager.createPoint(point2d.getX(), point2d.getY(), SUBTYPES.GEOM2D);
213
				lyr.setCoordTrans(getCoordTrans());
214
				lyr.addGraphic("gazetteer", point, pointSymbol, null);
215
				lyr.addGraphic("gazetteer", point, textSymbol, feature.getName());
216
				DeleteSearchesExtension.setVisible();
217
				PluginServices.getMainFrame().enableControls();
218
			} catch (CreateGeometryException e) {
219
			    LOG.error("Error creating the point", e);
220
			}
221
		}
222

  
223 216
		mc.invalidate();
224 217
	}
225 218

  
......
254 247
		return theSymbol;
255 248
	}
256 249

  
250
//	/**
251
//	 * Reprojects the new point
252
//	 * @param ptOrig
253
//	 * Origin point
254
//	 * @return
255
//	 * FPoint2D
256
//	 */
257
//	private Point2D getReprojectedPoint(Point2D ptOrigin){
258
//		Point2D ptDest = null;
259
//		ICoordTrans ct = getCoordTrans();
260
//		if(ct != null) {
261
//		    return ct.convert(ptOrigin, ptDest);
262
//		}
263
//		return ptOrigin;
264
//	}
265

  
266
	   /**
267
     * Reprojects the new point
268
     * @param ptOrig
269
     * Origin point
270
     * @return
271
     * Point
272
     */
273
    private Point getReprojectedPoint(Point ptOrigin){
274
        Point ptDest = ((Point)ptOrigin.cloneGeometry());
275
        ICoordTrans ct = getCoordTrans();
276
        if(ct != null) {
277
            ptDest.reProject(ct);
278
        }
279
        return ptDest;
280
    }
281

  
257 282
	/**
258
	 * Reprojects the new point
259
	 * @param ptOrig
260
	 * Origin point
261
	 * @return
262
	 * FPoint2D
263
	 */
264
	private Point2D getReprojectedPoint(Point2D ptOrigin){
265
		Point2D ptDest = null;
266
		ICoordTrans ct = getCoordTrans();
267
		if(ct != null) {
268
		    return ct.convert(ptOrigin, ptDest);
269
		}
270
		return ptOrigin;
271
	}
272
	/**
273 283
	 * @return the coordTrans
274 284
	 */
275 285
	public ICoordTrans getCoordTrans() {
org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/pom.xml
13 13
  <parent>
14 14
      <groupId>org.gvsig</groupId>
15 15
      <artifactId>org.gvsig.desktop</artifactId>
16
      <version>2.0.109-SNAPSHOT</version>
16
      <version>2.0.110</version>
17 17
  </parent>
18 18

  
19 19
  <url>https://devel.gvsig.org/redmine/projects/gvsig-gazetteer</url>
org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/querys/Feature.java
42 42
package org.gvsig.gazetteer.querys;
43 43
import java.awt.geom.Point2D;
44 44

  
45
import org.gvsig.fmap.geom.primitive.Point;
46

  
45 47
/**
46 48
 * This class represents a Feature into the WFS context
47
 * 
48
 * 
49
 *
50
 *
49 51
 * @author Jorge Piera Llodra (piera_jor@gva.es)
50 52
 */
51 53
public class Feature {
52 54
    private String Id;
53 55
    private String Name;
54 56
    private String Description;
55
    private Point2D coordinates;
57
    private Point coordinates;
56 58

  
57 59
/**
58
 * @param id 
59
 * @param name 
60
 * @param description 
61
 * @param coordinates 
60
 * @param id
61
 * @param name
62
 * @param description
63
 * @param coordinates
62 64
 */
63
    public  Feature(String id, String name, String description, Point2D coordinates) {        
65
    public  Feature(String id, String name, String description, Point coordinates) {
64 66
        super();
65 67
        Id = id;
66 68
        Name = name;
67 69
        Description = description;
68 70
        this.coordinates = coordinates;
69
    } 
71
    }
70 72

  
71 73
/**
72
 * 
73
 * 
74
 * 
74
 *
75
 *
76
 *
75 77
 * @return Returns the coordinates.
76 78
 */
77
    public Point2D getCoordinates() {        
79
    public Point getCoordinates() {
78 80
        return coordinates;
79
    } 
81
    }
80 82

  
81 83
/**
82
 * 
83
 * 
84
 * 
84
 *
85
 *
86
 *
85 87
 * @param coordinates The coordinates to set.
86 88
 */
87
    public void setCoordinates(Point2D coordinates) {        
89
    public void setCoordinates(Point coordinates) {
88 90
        this.coordinates = coordinates;
89
    } 
91
    }
90 92

  
91 93
/**
92
 * 
93
 * 
94
 * 
94
 *
95
 *
96
 *
95 97
 * @return Returns the description.
96 98
 */
97
    public String getDescription() {        
99
    public String getDescription() {
98 100
        return Description;
99
    } 
101
    }
100 102

  
101 103
/**
102
 * 
103
 * 
104
 * 
104
 *
105
 *
106
 *
105 107
 * @param description The description to set.
106 108
 */
107
    public void setDescription(String description) {        
109
    public void setDescription(String description) {
108 110
        Description = description;
109
    } 
111
    }
110 112

  
111 113
/**
112
 * 
113
 * 
114
 * 
114
 *
115
 *
116
 *
115 117
 * @return Returns the id.
116 118
 */
117
    public String getId() {        
119
    public String getId() {
118 120
        return Id;
119
    } 
121
    }
120 122

  
121 123
/**
122
 * 
123
 * 
124
 * 
124
 *
125
 *
126
 *
125 127
 * @param id The id to set.
126 128
 */
127
    public void setId(String id) {        
129
    public void setId(String id) {
128 130
        Id = id;
129
    } 
131
    }
130 132

  
131 133
/**
132
 * 
133
 * 
134
 * 
134
 *
135
 *
136
 *
135 137
 * @return Returns the name.
136 138
 */
137
    public String getName() {        
139
    public String getName() {
138 140
        return Name;
139
    } 
141
    }
140 142

  
141 143
/**
142
 * 
143
 * 
144
 * 
144
 *
145
 *
146
 *
145 147
 * @param name The name to set.
146 148
 */
147
    public void setName(String name) {        
149
    public void setName(String name) {
148 150
        Name = name;
149
    } 
151
    }
150 152

  
151 153
    /*
152 154
     * (non-Javadoc)
153 155
     * @see java.lang.Object#toString()
154 156
     */
155
    public String toString() {        
157
    public String toString() {
156 158
        return getDescription();
157
    } 
159
    }
158 160
 }
org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/geonames/GeonamesServiceDriver.java
37 37
import org.geonames.WebService;
38 38
import org.gvsig.catalog.drivers.DiscoveryServiceCapabilities;
39 39
import org.gvsig.catalog.exceptions.NotSupportedVersionException;
40
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
41
import org.gvsig.fmap.geom.GeometryLocator;
42
import org.gvsig.fmap.geom.GeometryManager;
43
import org.gvsig.fmap.geom.exception.CreateGeometryException;
40 44
import org.gvsig.gazetteer.drivers.AbstractGazetteerServiceDriver;
41 45
import org.gvsig.gazetteer.drivers.GazetteerCapabilities;
42 46
import org.gvsig.gazetteer.querys.Feature;
......
70 74
		return features;
71 75
	}
72 76

  
73
	private Feature converToponym(Toponym toponym) {
77
	private Feature converToponym(Toponym toponym) throws CreateGeometryException {
78
	    GeometryManager geomManager = GeometryLocator.getGeometryManager();
74 79
		Feature feature = new Feature(toponym.getFeatureCode(),
75 80
				toponym.getName(),
76 81
				toponym.getName(),
77
				new Point2D.Double(toponym.getLongitude(), toponym.getLatitude()));
82
				geomManager.createPoint(toponym.getLongitude(), toponym.getLatitude(), SUBTYPES.GEOM2D));
78 83

  
79 84
		return feature;
80 85
	}
org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/wfs/drivers/WFSGPEContentHandler.java
3 3
import java.awt.geom.Point2D;
4 4
import java.util.ArrayList;
5 5

  
6
import org.gvsig.fmap.geom.primitive.Point;
6 7
import org.gvsig.gazetteer.querys.Feature;
7 8
import org.gvsig.gpe.lib.impl.parser.GPEContentHandler;
8 9

  
......
58 59
 * @author Jorge Piera Llodr? (jorge.piera@iver.es)
59 60
 */
60 61
public class WFSGPEContentHandler extends GPEContentHandler{
61
	private ArrayList features  = null;	
62
	private ArrayList features  = null;
62 63
	private String searchField = null;
63 64

  
64 65
	public WFSGPEContentHandler(String searchField) {
......
83 84
	 * @see org.gvsig.gpe.GPEContentHandler#addGeometryToFeature(java.lang.Object, java.lang.Object)
84 85
	 */
85 86
	public void addGeometryToFeature(Object geometry, Object feature) {
86
		((Feature)feature).setCoordinates((Point2D)geometry);
87
		((Feature)feature).setCoordinates((Point)geometry);
87 88
	}
88 89

  
89 90
	/*
......
109 110
	 */
110 111
	public Object startFeature(String id, String name, String xsElementName,
111 112
			Object layer) {
112
		return new Feature(id, name, name, null);		
113
		return new Feature(id, name, name, null);
113 114
	}
114 115

  
115 116
	/*
......
118 119
	 */
119 120
	public Object startPoint(String id, double x, double y, double z, String srs) {
120 121
		return new Point2D.Double(x, y);
121
	}	
122
	}
122 123

  
123 124
	/* (non-Javadoc)
124 125
	 * @see org.gvsig.gpe.GPEContentHandler#startLineString(java.lang.String, double[], double[], double[], java.lang.String)
......
135 136
			String srs) {
136 137
		return getPoint(x, y);
137 138
	}
138
	
139
	private Point2D getPoint(double[] x, double y[]) {        
139

  
140
	private Point2D getPoint(double[] x, double y[]) {
140 141
		double xs = 0.0;
141 142
		double ys = 0.0;
142 143
		for (int i=0 ; i<x.length ; i++){
......
148 149
		}else{
149 150
			return new Point2D.Double(xs/x.length,ys/x.length);
150 151
		}
151
	} 
152
	
152
	}
153

  
153 154
	/**
154 155
	 * @author Jorge Piera Llodr? (jorge.piera@iver.es)
155 156
	 */
156 157
	private class Element{
157 158
		private String name = null;
158 159
		private Object value = null;
159
				
160

  
160 161
		public Element(String name, Object value) {
161 162
			super();
162 163
			this.name = name;
163 164
			this.value = value;
164 165
		}
165
		
166

  
166 167
		/**
167 168
		 * @return the name
168 169
		 */
169 170
		public String getName() {
170 171
			return name;
171 172
		}
172
		
173

  
173 174
		/**
174 175
		 * @param name the name to set
175 176
		 */
176 177
		public void setName(String name) {
177 178
			this.name = name;
178 179
		}
179
		
180

  
180 181
		/**
181 182
		 * @return the value
182 183
		 */
183 184
		public Object getValue() {
184 185
			return value;
185 186
		}
186
		
187

  
187 188
		/**
188 189
		 * @param value the value to set
189 190
		 */
190 191
		public void setValue(Object value) {
191 192
			this.value = value;
192
		}		
193
		}
193 194
	}
194 195

  
195 196
	/**
org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/adl/drivers/ADLGazetteerServiceDriver.java
72 72
	 * (non-Javadoc)
73 73
	 * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getCapabilities(java.net.URI)
74 74
	 */
75
	public DiscoveryServiceCapabilities getCapabilities(URI uri) {        
75
	public DiscoveryServiceCapabilities getCapabilities(URI uri) {
76 76
		GazetteerCapabilities capabilities = new GazetteerCapabilities();
77
		Collection nodes = new java.util.ArrayList();  
77
		Collection nodes = new java.util.ArrayList();
78 78
		URL url = null;
79 79
			try {
80 80
				url = uri.toURL();
......
82 82
				capabilities.setServerMessage("errorServerNotFound");
83 83
				capabilities.setAvailable(false);
84 84
				return capabilities;
85
			}        
85
			}
86 86
		try {
87 87
			nodes = new HTTPPostProtocol().doQuery(uri.toURL(),
88 88
					getPOSTMessageCapabilities(), 0);
......
90 90
			capabilities.setServerMessage(e.getMessage());
91 91
			capabilities.setAvailable(false);
92 92
			return capabilities;
93
		}		
93
		}
94 94
		AdlCapabilitiesParser parser = new AdlCapabilitiesParser(this, capabilities);
95 95
		parser.parse(nodes);
96 96
		return capabilities;
97
	} 
98
	
97
	}
98

  
99 99
	/**
100 100
	 * It creates the XML for the getCapabilities request
101 101
	 * @return Name-value pair with a XML request
102 102
	 */
103
	private String getPOSTMessageCapabilities() {        
103
	private String getPOSTMessageCapabilities() {
104 104
		return "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" +
105 105
		"<gazetteer-service " +
106 106
		"xmlns=\"http://www.alexandria.ucsb.edu/gazetteer\" " +
107 107
		"version=\"1.2\">" +
108 108
		"<get-capabilities-request/>" +
109
		"</gazetteer-service>";        
110
	} 	
111
	
109
		"</gazetteer-service>";
110
	}
111

  
112 112
	/*
113 113
	 * (non-Javadoc)
114 114
	 * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getFeature(java.net.URI, es.gva.cit.gazetteer.querys.Query)
115 115
	 */
116
	public Feature[] getFeature(URI uri, GazetteerQuery query) {        
116
	public Feature[] getFeature(URI uri, GazetteerQuery query) {
117 117
		Collection nodes = new java.util.ArrayList();
118 118
		setQuery(query);
119 119
		URL url = null;
......
122 122
		} catch (MalformedURLException e) {
123 123
			setServerAnswerReady("errorServerNotFound");
124 124
			return null;
125
		}    
125
		}
126 126
		System.out.println("**************POST*************");
127 127
		System.out.println(getPOSTGetFeature(getQuery(),true));
128 128
		nodes = new HTTPPostProtocol().doQuery(url,
......
138 138
		}else{
139 139
			return null;
140 140
		}
141
	} 
141
	}
142 142

  
143 143
	/**
144 144
	 * It creates the XML for the getFeature request
145 145
	 * @return Name-value pair with a XML request
146
	 * @param query 
146
	 * @param query
147 147
	 */
148
	private String getPOSTGetFeature(GazetteerQuery query,boolean withAccents) {        
148
	private String getPOSTGetFeature(GazetteerQuery query,boolean withAccents) {
149 149
		return  "<gazetteer-service " +
150 150
		"xmlns=\"http://www.alexandria.ucsb.edu/gazetteer\" " +
151 151
		"xmlns:gml=\"http://www.opengis.net/gml\" " +
152 152
		"version=\"1.2\">" +
153 153
		new ADLFilter(withAccents).getQuery(query) +
154 154
		"</gazetteer-service>" ;
155
	} 
156
	
155
	}
156

  
157 157
	/*
158 158
	 * (non-Javadoc)
159 159
	 * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#isProtocolSupported(java.net.URI)
160 160
	 */
161
	public boolean isProtocolSupported(URI uri) {        
161
	public boolean isProtocolSupported(URI uri) {
162 162
		// TODO Auto-generated method stub
163 163
		return true;
164
	} 	
164
	}
165 165

  
166 166
	/*
167 167
	 * (non-Javadoc)
org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/adl/parsers/AdlFeatureParser.java
40 40
*   dac@iver.es
41 41
*/
42 42
package org.gvsig.gazetteer.adl.parsers;
43
import java.awt.geom.Point2D;
44

  
43
import org.apache.commons.lang3.StringUtils;
45 44
import org.gvsig.catalog.metadataxml.XMLNode;
46 45
import org.gvsig.catalog.metadataxml.XMLTree;
46
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
47
import org.gvsig.fmap.geom.GeometryLocator;
48
import org.gvsig.fmap.geom.GeometryManager;
49
import org.gvsig.fmap.geom.exception.CreateGeometryException;
50
import org.gvsig.fmap.geom.primitive.Point;
47 51
import org.gvsig.gazetteer.querys.Feature;
52
import org.slf4j.Logger;
53
import org.slf4j.LoggerFactory;
48 54

  
49 55

  
50 56
/**
......
54 60
 */
55 61
public class AdlFeatureParser {
56 62

  
63
    private static final Logger logger =
64
        LoggerFactory.getLogger(AdlFeatureParser.class);
57 65
/**
58
 * @return 
59
 * @param node 
66
 * @return
67
 * @param node
68
 * @throws NumberFormatException
69
 * @throws CreateGeometryException
60 70
 */
61
    public static Feature[] parse(XMLNode node) {        
71
    public static Feature[] parse(XMLNode node) {
72
        GeometryManager geomManager = GeometryLocator.getGeometryManager();
73

  
62 74
        XMLNode[] nodeFeatures = XMLTree.searchMultipleNode(node,"query-response->standard-reports->gazetteer-standard-report");
63 75
        Feature[] features = new Feature[nodeFeatures.length];
64
        
76

  
65 77
        for (int i=0 ; i<nodeFeatures.length ; i++){
66 78
            String id = XMLTree.searchNodeValue(nodeFeatures[i],"identifier");
67 79
            String name = XMLTree.searchNodeValue(nodeFeatures[i],"names->name");
68 80
            String description = XMLTree.searchNodeValue(nodeFeatures[i],"display-name");
69
            Point2D.Double point = new Point2D.Double(Double.parseDouble(XMLTree.searchNodeValue(nodeFeatures[i],"bounding-box->gml:coord->gml:X")),
70
                    Double.parseDouble(XMLTree.searchNodeValue(nodeFeatures[i],"bounding-box->gml:coord->gml:Y")));
81
            Point point = null;
82
            double x = Double.parseDouble(XMLTree.searchNodeValue(nodeFeatures[i],"bounding-box->gml:coord->gml:X"));
83
            double y = Double.parseDouble(XMLTree.searchNodeValue(nodeFeatures[i],"bounding-box->gml:coord->gml:Y"));
84
            try {
85
                point = geomManager.createPoint(x, y, SUBTYPES.GEOM2D);
86
            } catch (CreateGeometryException | NumberFormatException e) {
87
                StringBuilder builder = new StringBuilder();
88
                builder.append("Can't create point: (");
89
                builder.append(x);
90
                builder.append(",");
91
                builder.append(y);
92
                builder.append(")");
93
                logger.warn(builder.toString());
94
            }
71 95
            features[i] = new Feature(id,name,description,point);
72 96
        }
73
        
97

  
74 98
        return features;
75
    } 
99
    }
76 100
 }
org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/utils/GazetteerGeometriesFactory.java
6 6

  
7 7
import org.slf4j.Logger;
8 8
import org.slf4j.LoggerFactory;
9

  
9
import org.gvsig.fmap.geom.primitive.Point;
10 10
import org.gvsig.gazetteer.querys.Feature;
11 11
import org.gvsig.xmlschema.lib.api.som.IXSTypeDefinition;
12 12

  
......
69 69
public class GazetteerGeometriesFactory {
70 70
	private static final Logger logger = LoggerFactory.getLogger(GazetteerGeometriesFactory.class);
71 71
	private String attName = null;
72
		
72

  
73 73
	public GazetteerGeometriesFactory(String attName) {
74 74
		super();
75 75
		this.attName = attName;
......
137 137
					sGeoname = (String)array.get(0);
138 138
				}
139 139
			}
140
		}		
140
		}
141 141
		return new Feature(null,
142 142
				sGeoname,
143 143
				sGeoname,
144
				(Point2D)geometry);
144
				(Point)geometry);
145 145
	}
146
	
146

  
147 147
	/*
148 148
	 * (non-Javadoc)
149 149
	 * @see org.gvsig.remoteClient.gml.factories.IGeometriesFactory#createPolygon2D(double[], double[])
......
159 159
			avX = avX/x.length;
160 160
			avY = avY/y.length;
161 161
		}
162
		return new Point2D.Double(avX, avY);		
162
		return new Point2D.Double(avX, avY);
163 163
	}
164 164
}
org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/idec/parsers/IdecFeatureParser.java
44 44

  
45 45
import org.gvsig.catalog.metadataxml.XMLNode;
46 46
import org.gvsig.catalog.metadataxml.XMLTree;
47
import org.gvsig.fmap.geom.GeometryLocator;
48
import org.gvsig.fmap.geom.GeometryManager;
49
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
50
import org.gvsig.fmap.geom.exception.CreateGeometryException;
51
import org.gvsig.fmap.geom.primitive.Point;
52
import org.gvsig.gazetteer.adl.parsers.AdlFeatureParser;
47 53
import org.gvsig.gazetteer.querys.Feature;
54
import org.slf4j.Logger;
55
import org.slf4j.LoggerFactory;
48 56

  
49 57

  
50 58
/**
51
 * 
52
 * 
53
 * 
59
 *
60
 *
61
 *
54 62
 * @author Jorge Piera Llodra (piera_jor@gva.es)
55 63
 */
56 64
public class IdecFeatureParser {
57

  
65
    private static final Logger logger =
66
        LoggerFactory.getLogger(IdecFeatureParser.class);
58 67
/**
59
 * @return 
60
 * @param node 
68
 * @return
69
 * @param node
61 70
 */
62
    public static Feature[] parse(XMLNode node) {        
63
    
71
    public static Feature[] parse(XMLNode node) {
72
        GeometryManager geomManager = GeometryLocator.getGeometryManager();
73

  
64 74
        XMLNode[] nodeFeatures = XMLTree.searchMultipleNode(node,"SOAP-ENV:Body->ns1:getCoordenadesUTMResponse->return->item");
65 75
        Feature[] features = new Feature[nodeFeatures.length];
66
        
76

  
67 77
        //New Version
68 78
        if (features.length == 0){
69 79
        	nodeFeatures = XMLTree.searchMultipleNode(node,"soapenv:Body->multiRef");
70 80
        	features = new Feature[nodeFeatures.length];
71 81
        }
72
        
82

  
73 83
        for (int i=0 ; i<nodeFeatures.length ; i++){
74 84
            String id = XMLTree.searchNodeValue(nodeFeatures[i],"NOM");
75 85
            String name = id;
76 86
            String description = id;
77
            Point2D.Double point = new Point2D.Double(Double.parseDouble(XMLTree.searchNodeValue(nodeFeatures[i],"X")),
78
                Double.parseDouble(XMLTree.searchNodeValue(nodeFeatures[i],"Y")));
87
            Point point = null;
88
            double x = Double.parseDouble(XMLTree.searchNodeValue(nodeFeatures[i],"X"));
89
            double y = Double.parseDouble(XMLTree.searchNodeValue(nodeFeatures[i],"Y"));
90
            try {
91
                point = geomManager.createPoint(x, y, SUBTYPES.GEOM2D);
92
            } catch (CreateGeometryException | NumberFormatException e) {
93
                StringBuilder builder = new StringBuilder();
94
                builder.append("Can't create point: (");
95
                builder.append(x);
96
                builder.append(",");
97
                builder.append(y);
98
                builder.append(")");
99
                logger.warn(builder.toString());
100
            }
79 101
            features[i] = new Feature(id,name,description,point);
80 102
        }
81
        
82
    
103

  
104

  
83 105
    return features;
84
    } 
106
    }
85 107
 }
org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/wfsg/parsers/WfsgFeatureParser.java
44 44

  
45 45
import org.gvsig.catalog.metadataxml.XMLNode;
46 46
import org.gvsig.catalog.metadataxml.XMLTree;
47
import org.gvsig.fmap.geom.GeometryLocator;
48
import org.gvsig.fmap.geom.GeometryManager;
49
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
50
import org.gvsig.fmap.geom.exception.CreateGeometryException;
51
import org.gvsig.fmap.geom.primitive.Point;
52
import org.gvsig.gazetteer.idec.parsers.IdecFeatureParser;
47 53
import org.gvsig.gazetteer.querys.Feature;
54
import org.slf4j.Logger;
55
import org.slf4j.LoggerFactory;
48 56

  
49 57

  
50 58
/**
51 59
 * This class is used to parse the getFeature request
52
 * 
53
 * 
60
 *
61
 *
54 62
 * @author Jorge Piera Llodra (piera_jor@gva.es)
55 63
 */
56 64
public class WfsgFeatureParser {
65
    private static final Logger logger =
66
        LoggerFactory.getLogger(WfsgFeatureParser.class);
57 67
	private String geomType = null;
58 68
	private String namespace = null;
59 69
	private static final String POSITION_NODE = "position->gml:Point->gml:coordinates";
......
62 72

  
63 73
	/**
64 74
	 * It parses the answer
65
	 * 
66
	 * 
75
	 *
76
	 *
67 77
	 * @return Array of features
68 78
	 * @param node XML tree that contains the getFeature Answer
69 79
	 * @param featureType FEature selected in the thesaurus list
70 80
	 * @param attribute Attribute to do the search
71 81
	 */
72
	public Feature[] parse(XMLNode node) {        
82
	public Feature[] parse(XMLNode node) {
73 83
		XMLNode[] nodeFeatures = XMLTree.searchMultipleNode(node,FEATUREMEMBER);
74
		namespace = "";       
84
		namespace = "";
75 85

  
76 86
		if ((nodeFeatures != null) && (nodeFeatures.length > 0)){
77 87
			if (nodeFeatures[0].getSubnodes().length > 0){
78 88
				String nodeName = nodeFeatures[0].getSubnodes()[0].getName();
79 89
				if (nodeName.split(":").length == 2){
80 90
					namespace = nodeName.split(":")[0] + ":";
81
				}  
91
				}
82 92
				return parseWFS(nodeFeatures,nodeName);
83
			}        	
84
		}       
93
			}
94
		}
85 95
		return null;
86
	} 
96
	}
87 97

  
88 98
	/**
89 99
	 * It parses the a WFS answer
90
	 * 
91
	 * 
100
	 *
101
	 *
92 102
	 * @return Array of features
93 103
	 * @param nodeFeatures XML tree that contains the Features
94 104
	 * @param featureType FEature selected in the thesaurus list
95 105
	 * @param attribute Attribute to do the search
96 106
	 * @param geomField Field that contains the geometry
97 107
	 */
98
	public Feature[] parseWFS(XMLNode[] nodeFeatures, String featureType) {        
108
	public Feature[] parseWFS(XMLNode[] nodeFeatures, String featureType) {
99 109
		Feature[] features = new Feature[nodeFeatures.length];
100 110

  
101 111

  
102 112
		for (int i=0 ; i<nodeFeatures.length ; i++){
103 113
			XMLNode nodeName = XMLTree.searchNode(nodeFeatures[i],featureType + "->" + GEOGRAPHICIDENTIFIER_NODE);
104
			String name = "";  
114
			String name = "";
105 115

  
106 116
			if (nodeName != null){
107 117
				if ((nodeName.getText() != null) && (!(nodeName.getText().equals("")))){
108 118
					name = nodeName.getText();
109 119
				} else if ((nodeName.getCdata() != null) && (!(nodeName.getCdata().equals("")))){
110
					name = nodeName.getCdata();                   
111
				}       
120
					name = nodeName.getCdata();
121
				}
112 122
			}
113 123

  
114 124
			String id = XMLTree.searchNodeAtribute(nodeFeatures[i],featureType,"fid");
115 125
			String description = name;
116
			Point2D point = getCoordinates(XMLTree.searchNodeValue(nodeFeatures[i],
126
			Point point = getCoordinates(XMLTree.searchNodeValue(nodeFeatures[i],
117 127
					featureType + "->" + POSITION_NODE));
118 128

  
119 129
			features[i] = new Feature(id,name,description,point);
120 130
		}
121 131
		return features;
122
	} 
132
	}
123 133

  
124 134
	/**
125 135
	 * It returns a pair of coordinates of the Feature
126
	 * @return 
136
	 * @return
127 137
	 * @param sCoordinates String that contains the coordinates
128 138
	 */
129
	private Point2D getCoordinates(String sCoordinates) {        
139
	private Point getCoordinates(String sCoordinates) {
140
	    GeometryManager geomManager = GeometryLocator.getGeometryManager();
130 141
		if (sCoordinates != null){
131 142
			double x = Double.parseDouble(sCoordinates.split(",")[0]);
132 143
			double y = Double.parseDouble(sCoordinates.split(",")[1]);
133
			return new Point2D.Double(x,y);
134
		}return null;    
135
	} 
144
			Point point =null;
145
			try {
146
                point = geomManager.createPoint(x, y, SUBTYPES.GEOM2D);
147
            } catch (CreateGeometryException | NumberFormatException e) {
148
                StringBuilder builder = new StringBuilder();
149
                builder.append("Can't create point: (");
150
                builder.append(x);
151
                builder.append(",");
152
                builder.append(y);
153
                builder.append(")");
154
                logger.warn(builder.toString());
155
            }
156
			return point;
157
		}return null;
158
	}
136 159

  
137 160

  
138 161

  
org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/ui/showresults/ShowResultsDialogPanel.java
47 47
import javax.swing.JDialog;
48 48
import javax.swing.JPanel;
49 49

  
50
import org.gvsig.fmap.geom.primitive.Point;
50 51
import org.gvsig.gazetteer.GazetteerClient;
51 52
import org.gvsig.gazetteer.querys.Feature;
52 53
import org.gvsig.gazetteer.querys.GazetteerQuery;
53 54

  
54 55

  
55 56
/**
56
 * 
57
 * 
58
 * 
57
 *
58
 *
59
 *
59 60
 * @author Jorge Piera Llodra (piera_jor@gva.es)
60 61
 */
61 62
public class ShowResultsDialogPanel extends JPanel implements ActionListener {
......
72 73
	protected GazetteerQuery query = null;
73 74

  
74 75
	/**
75
	 * @param client 
76
	 * @param features 
77
	 * @param recordsByPage 
78
	 * @param translator 
76
	 * @param client
77
	 * @param features
78
	 * @param recordsByPage
79
	 * @param translator
79 80
	 */
80
	public ShowResultsDialogPanel(GazetteerClient client, Feature[] features, int recordsByPage, GazetteerQuery query) {        
81
	public ShowResultsDialogPanel(GazetteerClient client, Feature[] features, int recordsByPage, GazetteerQuery query) {
81 82
		this.client = client;
82 83
		this.currentPage = 1;
83 84
		this.recordsByPage = recordsByPage;
84 85
		this.query = query;
85
		initialize(client,features,recordsByPage);     
86
	} 
86
		initialize(client,features,recordsByPage);
87
	}
87 88

  
88 89
	/**
89
	 * 
90
	 * 
91
	 * 
92
	 * @param client 
93
	 * @param features 
94
	 * @param recordsByPage 
90
	 *
91
	 *
92
	 *
93
	 * @param client
94
	 * @param features
95
	 * @param recordsByPage
95 96
	 */
96
	public void initialize(GazetteerClient client, Feature[] features, int recordsByPage) {        
97
	public void initialize(GazetteerClient client, Feature[] features, int recordsByPage) {
97 98
		this.featuresLength = features.length;
98 99
		this.currentPage = 1;
99 100
		this.recordsByPage = recordsByPage;
......
101 102
		setDefaultButtonListeners();
102 103

  
103 104
		add(ppalPanel);
104
	} 
105
	}
105 106

  
106 107
	/**
107
	 * 
108
	 * 
108
	 *
109
	 *
109 110
	 */
110
	private void setDefaultButtonListeners() {        
111
	private void setDefaultButtonListeners() {
111 112
		nextButton = ppalPanel.getNextButton();
112 113
		lastButton = ppalPanel.getLastButton();
113 114
		mapButton = ppalPanel.getMapButton();
......
117 118
		lastButton.addActionListener(this);
118 119
		mapButton.addActionListener(this);
119 120
		closeButton.addActionListener(this);
120
	} 
121
	}
121 122

  
122 123
	/**
123
	 * 
124
	 * 
125
	 * 
126
	 * @param e 
124
	 *
125
	 *
126
	 *
127
	 * @param e
127 128
	 */
128
	public void actionPerformed(ActionEvent e) {        
129
	public void actionPerformed(ActionEvent e) {
129 130
		if (e.getActionCommand().equals("next")) {
130 131
			nextButtonActionPerformed();
131
		} 
132
		}
132 133
		if (e.getActionCommand().equals("last")) {
133 134
			lastButtonActionPerformed();
134
		} 
135
		}
135 136
		if (e.getActionCommand().equals("localize")) {
136 137
			loadButtonActionPerformed();
137
		} 
138
		}
138 139
		if (e.getActionCommand().equals("close")) {
139 140
			closeButtonActionPerformed();
140 141
		}
141 142

  
142
	} 
143
	}
143 144

  
144 145
	/**
145
	 * 
146
	 * 
147
	 * 
148
	 * @return 
146
	 *
147
	 *
148
	 *
149
	 * @return
149 150
	 */
150
	private int getNumPages() {        
151
	private int getNumPages() {
151 152
		if ((featuresLength % recordsByPage) == 0)
152 153
			return featuresLength/recordsByPage;
153 154
		return (featuresLength/recordsByPage) + 1;
154
	} 
155
	}
155 156

  
156 157
	/**
157
	 * 
158
	 * 
158
	 *
159
	 *
159 160
	 */
160
	public void nextButtonActionPerformed() {        
161
	public void nextButtonActionPerformed() {
161 162
		this.currentPage = this.currentPage + 1;
162 163

  
163 164
		if (this.currentPage == getNumPages()) {
......
169 170
		ppalPanel.actualizaLabel(currentPage,recordsByPage);
170 171

  
171 172

  
172
	} 
173
	}
173 174

  
174 175
	/**
175
	 * 
176
	 * 
176
	 *
177
	 *
177 178
	 */
178
	public void lastButtonActionPerformed() {        
179
	public void lastButtonActionPerformed() {
179 180
		this.currentPage = this.currentPage - 1;
180 181
		if (this.currentPage == 1) {
181 182
			lastButton.setEnabled(false);
......
187 188
		ppalPanel.actualizaLabel(currentPage,recordsByPage);
188 189

  
189 190

  
190
	} 
191
	}
191 192

  
192 193
	/**
193
	 * 
194
	 * 
194
	 *
195
	 *
195 196
	 */
196
	public void loadButtonActionPerformed() {        
197
	public void loadButtonActionPerformed() {
197 198
		Feature feature = ppalPanel.getFeature();
198 199

  
199 200
		if (feature != null){
200 201
			System.out.println("ID: " + feature.getId());
201 202
			System.out.println("NAME: " + feature.getName());
202 203
			System.out.println("DESCRIPTION: " + feature.getDescription());
203
			System.out.println("COORDINATES: X=" + feature.getCoordinates().getX() + " Y=" + feature.getCoordinates().getY());
204
			Point point = feature.getCoordinates();
205
            if (point != null) {
206
                System.out.println(
207
                    "COORDINATES: X=" + point.getX() + " Y=" + point.getY());
208
            }
204 209
		}
205
	} 
210
	}
206 211

  
207 212
	/**
208
	 * 
209
	 * 
213
	 *
214
	 *
210 215
	 */
211
	public void closeButtonActionPerformed() {        
216
	public void closeButtonActionPerformed() {
212 217
		parent.setVisible(false);
213
	} 
218
	}
214 219

  
215 220
	/**
216
	 * 
217
	 * 
218
	 * 
221
	 *
222
	 *
223
	 *
219 224
	 * @param parent The parent to set.
220 225
	 */
221
	public void setParent(JDialog parent) {        
226
	public void setParent(JDialog parent) {
222 227
		this.parent = parent;
223
	} 
228
	}
224 229
}
org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/test/java/org/gvsig/gazetteer/drivers/ExampleNewDriver.java
5 5

  
6 6
import org.gvsig.catalog.drivers.DiscoveryServiceCapabilities;
7 7
import org.gvsig.catalog.ui.search.SearchAditionalPropertiesPanel;
8
import org.gvsig.fmap.geom.GeometryLocator;
9
import org.gvsig.fmap.geom.GeometryManager;
10
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
11
import org.gvsig.fmap.geom.exception.CreateGeometryException;
12
import org.gvsig.fmap.geom.primitive.Point;
8 13
import org.gvsig.gazetteer.querys.Feature;
9 14
import org.gvsig.gazetteer.querys.GazetteerQuery;
15
import org.gvsig.gazetteer.wfsg.parsers.WfsgFeatureParser;
16
import org.slf4j.Logger;
17
import org.slf4j.LoggerFactory;
10 18

  
11 19

  
12 20
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
......
62 70
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
63 71
 */
64 72
public class ExampleNewDriver extends AbstractGazetteerServiceDriver {
73
    private static final Logger logger =
74
        LoggerFactory.getLogger(ExampleNewDriver.class);
65 75

  
66 76
	/*
67 77
	 * (non-Javadoc)
......
76 86
	 * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getFeature(java.net.URI, es.gva.cit.gazetteer.querys.Query)
77 87
	 */
78 88
	public Feature[] getFeature(URI uri, GazetteerQuery query) throws Exception {
89
	    GeometryManager geomManager = GeometryLocator.getGeometryManager();
90

  
79 91
		String prop = (String)query.getProperty("PROP1");
80 92
		Feature[] features = new Feature[1];
81
		features[0] = new Feature("1","Result 1","description 1",new Point2D.Double(0,0));
93
		Point point =null;
94
		double x=0.0;
95
		double y=0.0;
96
        try {
97
            point = geomManager.createPoint(x, y, SUBTYPES.GEOM2D);
98
        } catch (CreateGeometryException | NumberFormatException e) {
99
            StringBuilder builder = new StringBuilder();
100
            builder.append("Can't create point: (");
101
            builder.append(x);
102
            builder.append(",");
103
            builder.append(y);
104
            builder.append(")");
105
            logger.warn(builder.toString());
106
        }
107
		features[0] = new Feature("1","Result 1","description 1",point);
82 108
		return features;
83 109
	}
84 110

  
......
89 115
	public String getServiceName() {
90 116
		return "My service";
91 117
	}
92
	
118

  
93 119
	/*
94 120
	 * (non-Javadoc)
95 121
	 * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getAditionalSearchPanel()

Also available in: Unified diff