Statistics
| Revision:

gvsig-vectorediting / org.gvsig.vectorediting / trunk / org.gvsig.vectorediting / org.gvsig.vectorediting.lib / org.gvsig.vectorediting.lib.impl / src / main / java / org / gvsig / vectorediting / lib / impl / DefaultEditingProviderServices.java @ 2109

History | View | Annotate | Download (24.7 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright ? 2007-2014 gvSIG Association
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.vectorediting.lib.impl;
25

    
26
import java.util.Iterator;
27
import java.util.List;
28
import java.util.Map;
29
import org.gvsig.euclidean.EuclideanLine2D;
30
import org.gvsig.expressionevaluator.GeometryExpressionBuilder;
31
import org.gvsig.fmap.dal.DALLocator;
32
import org.gvsig.fmap.dal.DataManager;
33

    
34
import org.gvsig.fmap.dal.EditingNotification;
35
import org.gvsig.fmap.dal.EditingNotificationManager;
36
import org.gvsig.fmap.dal.exception.DataException;
37
import org.gvsig.fmap.dal.expressionevaluator.DALExpressionBuilder;
38
import org.gvsig.fmap.dal.feature.EditableFeature;
39
import org.gvsig.fmap.dal.feature.Feature;
40
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
41
import org.gvsig.fmap.dal.feature.FeatureSet;
42
import org.gvsig.fmap.dal.feature.FeatureStore;
43
import org.gvsig.fmap.dal.feature.FeatureType;
44
import org.gvsig.fmap.dal.swing.DALSwingLocator;
45
import org.gvsig.fmap.geom.Geometry;
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.GeometryUtils;
50
import org.gvsig.fmap.geom.exception.CreateGeometryException;
51
import org.gvsig.fmap.geom.operation.GeometryOperationException;
52
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
53
import org.gvsig.fmap.geom.primitive.Arc;
54
import org.gvsig.fmap.geom.primitive.Circle;
55
import org.gvsig.fmap.geom.primitive.Ellipse;
56
import org.gvsig.fmap.geom.primitive.Line;
57
import org.gvsig.fmap.geom.primitive.Point;
58
import org.gvsig.fmap.geom.primitive.Spline;
59
import org.gvsig.fmap.geom.type.GeometryType;
60
import org.gvsig.fmap.mapcontext.MapContext;
61
import org.gvsig.fmap.mapcontext.layers.CancelationException;
62
import org.gvsig.fmap.mapcontext.layers.FLayer;
63
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
64
import org.gvsig.tools.ToolsLocator;
65
import org.gvsig.tools.exception.BaseException;
66
import org.gvsig.tools.i18n.I18nManager;
67
import org.gvsig.tools.service.spi.AbstractProviderServices;
68
import org.gvsig.vectorediting.lib.spi.EditingProviderServices;
69
import org.slf4j.Logger;
70
import org.slf4j.LoggerFactory;
71

    
72
public class DefaultEditingProviderServices extends AbstractProviderServices
73
        implements EditingProviderServices {
74

    
75
    private static final Logger LOGGER = LoggerFactory
76
            .getLogger(DefaultEditingProviderServices.class);
77

    
78
    @Override
79
    public void insertFeatureIntoFeatureStore(Feature feature,
80
            FeatureStore featureStore) {
81
        EditableFeature eFeature = null;
82
        try {
83

    
84
            if (feature instanceof EditableFeature) {
85
                eFeature = (EditableFeature) feature;
86
            } else {
87
                eFeature = feature.getEditable();
88
            }
89

    
90
            EditingNotificationManager editingNotificationManager
91
                    = DALSwingLocator.getEditingNotificationManager();
92

    
93
            EditingNotification notification
94
                    = editingNotificationManager.notifyObservers(this, // source
95
                            EditingNotification.BEFORE_INSERT_FEATURE, // type
96
                            null,// document
97
                            null,// layer
98
                            featureStore,// store
99
                            eFeature// feature
100
                    );
101

    
102
            if (notification.isCanceled()) {
103
                String msg
104
                        = String
105
                                .format(
106
                                        "Can't insert feature into %1$s, canceled by some observer.",
107
                                        featureStore.getName());
108
                throw new CancelationException(msg, null);
109
            }
110

    
111
            if (notification.shouldValidateTheFeature()) {
112
                if (!editingNotificationManager.validateFeature(eFeature)) {
113
                    String msg
114
                            = String.format("%1$s is not valid", eFeature.toString());
115
                    throw new Exception(msg);
116
                }
117
            }
118

    
119
            featureStore.insert(eFeature);
120

    
121
            editingNotificationManager.notifyObservers(this,
122
                    EditingNotification.AFTER_INSERT_FEATURE, null, null,
123
                    featureStore, eFeature);
124

    
125
        } catch (Exception e) {
126
            String msg
127
                    = String.format("Can't insert %1$s into %2$s",
128
                            eFeature.toString(), featureStore.getName());
129
            LOGGER.info(msg, e);
130
        }
131
    }
132

    
133
    @Override
134
    public void insertGeometryIntoFeatureStore(Geometry geometry,
135
            FeatureStore featureStore) {
136
        EditableFeature eFeature = null;
137

    
138
        try {
139
            eFeature = featureStore.createNewFeature(true);
140

    
141
            eFeature.setGeometry(featureStore.getDefaultFeatureType()
142
                    .getDefaultGeometryAttributeName(), geometry);
143

    
144
            EditingNotificationManager editingNotificationManager
145
                    = DALSwingLocator.getEditingNotificationManager();
146

    
147
            EditingNotification notification
148
                    = editingNotificationManager.notifyObservers(this, // source
149
                            EditingNotification.BEFORE_INSERT_FEATURE, // type
150
                            null,// document
151
                            null,// layer
152
                            featureStore,// store
153
                            eFeature// feature
154
                    );
155

    
156
            if (notification.isCanceled()) {
157
                String msg
158
                        = String
159
                                .format(
160
                                        "Can't insert geometry into %1$s, canceled by some observer.",
161
                                        featureStore.getName());
162
                throw new CancelationException(msg, null);
163
            }
164

    
165
            if (notification.shouldValidateTheFeature()) {
166
                if (!editingNotificationManager.validateFeature(eFeature)) {
167
                    String msg
168
                            = String.format("%1$s is not valid", eFeature.toString());
169
                    throw new Exception(msg);
170
                }
171
            }
172

    
173
            featureStore.insert(eFeature);
174

    
175
            editingNotificationManager.notifyObservers(this,
176
                    EditingNotification.AFTER_INSERT_FEATURE, null, null,
177
                    featureStore, eFeature);
178

    
179
        } catch (Exception e) {
180
            String msg
181
                    = String.format("Can't insert %1$s into %2$s",
182
                            eFeature.toString(), featureStore.getName());
183
            LOGGER.info(msg, e);
184
        }
185
    }
186

    
187
    @Override
188
    public void deleteFeatureFromFeatureSet(Feature feature,
189
            FeatureStore featureStore, FeatureSet set) {
190

    
191
        try {
192
            EditingNotificationManager editingNotificationManager
193
                    = DALSwingLocator.getEditingNotificationManager();
194

    
195
            EditingNotification notification
196
                    = editingNotificationManager.notifyObservers(this, // source
197
                            EditingNotification.BEFORE_REMOVE_FEATURE, // type
198
                            null,// document
199
                            null,// layer
200
                            featureStore,// store
201
                            feature// feature
202
                    );
203

    
204
            if (notification.isCanceled()) {
205
                String msg
206
                        = String
207
                                .format(
208
                                        "Can't delete feature from %1$s, canceled by some observer.",
209
                                        featureStore.getName());
210
                throw new CancelationException(msg, null);
211
            }
212

    
213
            set.delete(feature);
214

    
215
            editingNotificationManager.notifyObservers(this,
216
                    EditingNotification.AFTER_REMOVE_FEATURE, null, null,
217
                    featureStore, feature);
218

    
219
        } catch (Exception e) {
220
            LOGGER.warn(e.getMessage(), e);
221
        }
222
    }
223

    
224
    @Override
225
    public void deleteFeatureFromFeatureStore(Feature feature,
226
            FeatureStore featureStore) {
227

    
228
        try {
229
            EditingNotificationManager editingNotificationManager
230
                    = DALSwingLocator.getEditingNotificationManager();
231

    
232
            EditingNotification notification
233
                    = editingNotificationManager.notifyObservers(this, // source
234
                            EditingNotification.BEFORE_REMOVE_FEATURE, // type
235
                            null,// document
236
                            null,// layer
237
                            featureStore,// store
238
                            feature// feature
239
                    );
240

    
241
            if (notification.isCanceled()) {
242
                String msg
243
                        = String
244
                                .format(
245
                                        "Can't delete feature from %1$s, canceled by some observer.",
246
                                        featureStore.getName());
247
                throw new CancelationException(msg, null);
248
            }
249

    
250
            featureStore.delete(feature);
251

    
252
            editingNotificationManager.notifyObservers(this,
253
                    EditingNotification.AFTER_REMOVE_FEATURE, null, null,
254
                    featureStore, feature);
255

    
256
        } catch (Exception e) {
257
            LOGGER.warn(e.getMessage(), e);
258
        }
259
    }
260

    
261
    @Override
262
    public void updateFeatureInFeatureStore(Feature feature,
263
            FeatureStore featureStore) {
264
        EditableFeature eFeature = null;
265

    
266
        try {
267

    
268
            if (feature instanceof EditableFeature) {
269
                eFeature = (EditableFeature) feature;
270
            } else {
271
                eFeature = feature.getEditable();
272
            }
273

    
274
            EditingNotificationManager editingNotificationManager
275
                    = DALSwingLocator.getEditingNotificationManager();
276

    
277
            EditingNotification notification
278
                    = editingNotificationManager.notifyObservers(this, // source
279
                            EditingNotification.BEFORE_UPDATE_FEATURE, // type
280
                            null,// document
281
                            null,// layer
282
                            featureStore,// store
283
                            eFeature// feature
284
                    );
285

    
286
            if (notification.isCanceled()) {
287
                String msg
288
                        = String
289
                                .format(
290
                                        "Can't update feature in %1$s, canceled by some observer.",
291
                                        featureStore.getName());
292
                throw new CancelationException(msg, null);
293
            }
294

    
295
            if (notification.shouldValidateTheFeature()) {
296
                if (!editingNotificationManager.validateFeature(eFeature)) {
297
                    String msg
298
                            = String.format("%1$s is not valid", eFeature.toString());
299
                    throw new Exception(msg);
300
                }
301
            }
302

    
303
            featureStore.update(eFeature);
304
            editingNotificationManager.notifyObservers(this,
305
                    EditingNotification.AFTER_UPDATE_FEATURE, null, null,
306
                    featureStore, eFeature);
307

    
308
        } catch (Exception e) {
309
            String msg
310
                    = String.format("Can't update %1$s in %2$s", eFeature.toString(),
311
                            featureStore.getName());
312
            LOGGER.info(msg, e);
313
        }
314
    }
315

    
316
    @Override
317
    public Circle createCircle(Point center, double radius, int subtype)
318
            throws CreateGeometryException {
319
        return GeometryUtils.createCircle(center, radius, subtype);
320
    }
321

    
322
    @Override
323
    public Circle createCircle(Point firstPoint, Point secondPoint,
324
            Point thridPoint, int subtype) throws CreateGeometryException {
325
        return GeometryUtils.createCircle(firstPoint, secondPoint, thridPoint, subtype);
326
    }
327

    
328
    @Override
329
    public Arc createArc(Point center, double radius, double startAngle,
330
            double angleExt, int subtype) throws CreateGeometryException {
331
        return GeometryUtils.createArc(center, radius, startAngle, angleExt, subtype);
332
    }
333

    
334
    @Override
335
    public Ellipse createFilledEllipse(Point firstPointAxisA,
336
            Point secondPointAxisA, double halfLengthAxisB, int subtype)
337
            throws CreateGeometryException {
338
        return GeometryUtils.createFilledEllipse(firstPointAxisA, secondPointAxisA, halfLengthAxisB, subtype);
339
    }
340

    
341
    @Override
342
    public Arc createArc(Point start, Point middle, Point end, int subtype)
343
            throws BaseException {
344
        return GeometryUtils.createArc(start, middle, end, subtype);
345
    }
346

    
347
    @Override
348
    public Point createPoint(double x, double y, int subtype)
349
            throws CreateGeometryException {
350
        GeometryManager geomManager = GeometryLocator.getGeometryManager();
351
        return geomManager.createPoint(x, y, subtype);
352
    }
353

    
354
    @Override
355
    public Line createLine(double x1, double y1, double x2, double y2,
356
            int subtype) throws CreateGeometryException {
357
        return GeometryUtils.createLine(x1, y1, x2, y2, subtype);
358
    }
359

    
360
    @Override
361
    public int getSubType(FeatureStore featureStore) throws DataException {
362

    
363
        GeometryType geomType = getGeomType(featureStore);
364
        if (geomType != null) {
365
            return geomType.getSubType();
366
        }
367
        return SUBTYPES.UNKNOWN;
368
    }
369

    
370
    @Override
371
    public GeometryType getGeomType(FeatureStore featureStore)
372
            throws DataException {
373
        return featureStore.getDefaultFeatureType()
374
                .getDefaultGeometryAttribute().getGeomType();
375
    }
376

    
377
    @Override
378
    public EditableFeature getFeatureCopyWithoutPK(FeatureStore featureStore,
379
            Feature feature) throws DataException {
380
        EditableFeature editableFeature
381
                = featureStore.createNewFeature(feature.getType(), true);
382

    
383
        FeatureType type_src = feature.getType();
384
        @SuppressWarnings("rawtypes")
385
        Iterator iterator = type_src.iterator();
386
        FeatureType type_dest = editableFeature.getType();
387

    
388
        while (iterator.hasNext()) {
389
            FeatureAttributeDescriptor attribute_src
390
                    = (FeatureAttributeDescriptor) iterator.next();
391

    
392
            FeatureAttributeDescriptor attribute_dest
393
                    = type_dest.getAttributeDescriptor(attribute_src.getName());
394
            if (attribute_dest != null) {
395
                if (!attribute_dest.isPrimaryKey()) {
396
                    editableFeature.set(attribute_dest.getIndex(),
397
                            feature.get(attribute_src.getIndex()));
398
                }
399
            }
400
        }
401
        return editableFeature;
402
    }
403

    
404
    @Override
405
    public Point getCenter(Point a, Point b, Point c, int subtype)
406
            throws CreateGeometryException {
407
        return GeometryUtils.getCenter(a, b, c, subtype);
408
    }
409

    
410
    @Override
411
    public Point getMidPoint(Point a, Point b, int subtype)
412
            throws CreateGeometryException {
413
        return GeometryUtils.getMidPoint(a, b, subtype);
414
    }
415

    
416
    @Override
417
    public Double[] getLineParams(Point point, Point nextPoint) {
418
        Double[] lineParams = new Double[2];
419
        double denom = nextPoint.getX() - point.getX();
420
        if (denom != 0) {
421
            lineParams[0] = (nextPoint.getY() - point.getY()) / denom;
422
            lineParams[1] = point.getY() - (lineParams[0] * point.getX());
423
        } else {
424
            if (nextPoint.getY() >= point.getY()) {
425
                lineParams[0] = Double.POSITIVE_INFINITY;
426
                lineParams[1] = Double.NEGATIVE_INFINITY;
427
                if (point.getX() == 0) {
428
                    lineParams[1] = 0.0;
429
                }
430
            } else {
431
                lineParams[0] = Double.NEGATIVE_INFINITY;
432
                lineParams[1] = Double.POSITIVE_INFINITY;
433
                if (point.getX() == 0) {
434
                    lineParams[1] = 0.0;
435
                }
436
            }
437
        }
438
        return lineParams;
439
    }
440

    
441
    @Override
442
    public Point[] getPerpendicular(Double m, Double b, Point point, int subtype)
443
            throws CreateGeometryException {
444
        // Pendiente de la recta perpendicular
445
        Double m1 = -1 / m;
446

    
447
        // b de la funcion de la recta perpendicular
448
        Double b1 = point.getY() - (m1 * point.getX());
449

    
450
        // Obtenemos un par de puntos
451
        Point[] res = new Point[2];
452

    
453
        if (Double.isInfinite(m1)) {
454
            if (m1 > 0) {
455
                //return the director vector of the line
456
                res[0] = createPoint(point.getX(), 0.0, subtype);
457
                res[1] = createPoint(point.getX(), 1.0, subtype);
458
            } else {
459
                res[0] = createPoint(point.getX(), 0.0, subtype);
460
                res[1] = createPoint(point.getX(), -1.0, subtype);
461
            }
462
        } else {
463
            //return the director vector of the line
464
            res[0] = createPoint(0.0, b1, subtype);
465
            Double mod = Math.sqrt(1+Math.pow(m1,2));
466
            Double x = 1/mod;
467
            Double y = m1*x + b1;
468
            res[1] = createPoint(x, y, subtype);
469
        }
470

    
471
        return res;
472
    }
473

    
474
    @Override
475
    public Point getIntersection(Point[] lineA, Point[] lineB, int subtype)
476
            throws CreateGeometryException {
477
        Point p1 = lineA[0];
478
        Point p2 = lineA[1];
479
        Point p3 = lineB[0];
480
        Point p4 = lineB[1];
481

    
482
        double m1 = Double.POSITIVE_INFINITY;
483

    
484
        if ((p2.getX() - p1.getX()) != 0) {
485
            m1 = (p2.getY() - p1.getY()) / (p2.getX() - p1.getX());
486
        }
487

    
488
        double m2 = Double.POSITIVE_INFINITY;
489

    
490
        if ((p4.getX() - p3.getX()) != 0) {
491
            m2 = (p4.getY() - p3.getY()) / (p4.getX() - p3.getX());
492
        }
493

    
494
        if ((m1 == Double.POSITIVE_INFINITY)
495
                && (m2 == Double.POSITIVE_INFINITY)) {
496
            return null;
497
        }
498

    
499
        double b1 = p2.getY() - (m1 * p2.getX());
500

    
501
        double b2 = p4.getY() - (m2 * p4.getX());
502

    
503
        if ((m1 != Double.POSITIVE_INFINITY)
504
                && (m2 != Double.POSITIVE_INFINITY)) {
505
            if (m1 == m2) {
506
                return null;
507
            }
508

    
509
            double x = (b2 - b1) / (m1 - m2);
510

    
511
            return createPoint(x, (m1 * x) + b1, subtype);
512
        } else if (m1 == Double.POSITIVE_INFINITY) {
513
            double x = p1.getX();
514

    
515
            return createPoint(x, (m2 * x) + b2, subtype);
516
        } else if (m2 == Double.POSITIVE_INFINITY) {
517
            double x = p3.getX();
518

    
519
            return createPoint(x, (m1 * x) + b1, subtype);
520
        }
521

    
522
        return null;
523
    }
524

    
525
    @Override
526
    public double getAngle(Point start, Point end)
527
            throws GeometryOperationNotSupportedException,
528
            GeometryOperationException {
529
        double angle
530
                = Math.acos((end.getX() - start.getX()) / start.distance(end));
531

    
532
        if (start.getY() > end.getY()) {
533
            angle = -angle;
534
        }
535

    
536
        if (angle < 0) {
537
            angle += (2 * Math.PI);
538
        }
539

    
540
        return angle;
541
    }
542

    
543
    @Override
544
    public double angleDistance(double angle1, double angle2) {
545
        double result = angle2 - angle1;
546
        if (result < 0) {
547
            result = (Math.PI * 2) + result;
548
        }
549
        return result;
550
    }
551

    
552
    @Override
553
    public Line createLine(Point p1, Point p2, int subtype)
554
            throws CreateGeometryException {
555
        return GeometryUtils.createLine(p1, p2, subtype);
556
    }
557

    
558
    @Override
559
    public Spline createSpline(List<Point> points, int subtype)
560
            throws CreateGeometryException {
561
        return GeometryUtils.createSpline(points, subtype);
562
    }
563

    
564
    @Override
565
    public String makeConsoleMessage(String preText, Map<String, String> options) {
566

    
567
        I18nManager i18nManager = ToolsLocator.getI18nManager();
568

    
569
        StringBuilder stb = new StringBuilder();
570

    
571
        if (preText != null) {
572
            stb.append(i18nManager.getTranslation(preText));
573
            stb.append(" ");
574
        }
575

    
576
        for (String option : options.keySet()) {
577
            stb.append("[");
578
            stb.append(option);
579
            stb.append("]");
580
            stb.append(i18nManager.getTranslation(options.get(option)));
581
            stb.append(" ");
582
        }
583

    
584
        return stb.toString();
585
    }
586

    
587
    @Override
588
    public Arc createEllipse(Point firstPointAxisA, Point secondPointAxisA,
589
            double halfLengthAxisB, int subtype) throws CreateGeometryException {
590
        return GeometryUtils.createEllipse(firstPointAxisA, secondPointAxisA, halfLengthAxisB, subtype);
591
    }
592

    
593
    @Override
594
    public Circle createCircle(Point firstPoint, Point secondPoint, Point thirdPoint, Point fourthPoint, Point fifthPoint, int subtype) throws CreateGeometryException {
595
        return GeometryUtils.createCircle(firstPoint, secondPoint, thirdPoint, fourthPoint, fifthPoint, subtype);
596
    }
597

    
598
    @Override
599
    public Circle createCircle(EuclideanLine2D line1, EuclideanLine2D line2, Point point, int subtype) throws CreateGeometryException {
600
        return GeometryUtils.createCircle(line1, line2, point, subtype);
601
    }
602

    
603
    @Override
604
    public Circle createCircle(Geometry geometry1, Geometry geometry2, double radius, Point firstPoint, Point secondPoint, int subtype) throws CreateGeometryException {
605
        return GeometryUtils.createCircle(geometry1, geometry2, radius, firstPoint, secondPoint, subtype);
606
    }
607

    
608
    @Override
609
    public Geometry getGeometry(Point point, FeatureStore store, MapContext mapContext) {
610
        Geometry geometry = null;
611
        try {
612
            double tolerance = mapContext.getViewPort().toMapDistance(mapContext.getLayers().getDefaultTolerance());
613
            Geometry buffer = point.buffer(tolerance);
614
            
615
            DataManager dataManager = DALLocator.getDataManager();
616
            DALExpressionBuilder dalBuilder = dataManager.createDALExpressionBuilder();
617
            GeometryExpressionBuilder builder = dalBuilder.expression();
618
            String filter = builder.ST_Intersects(builder.geometry(buffer, mapContext.getProjection()), dalBuilder.geometry()).toString();
619
            String sortBy = builder.ST_Distance(builder.geometry(buffer), dalBuilder.geometry()).toString();
620

    
621
            Feature f;
622
                f = store.findFirst(filter, sortBy, true);
623
            if(f!=null){
624
                geometry = f.getDefaultGeometry();
625
            }
626
         
627
        } catch (Exception ex) {
628
            LOGGER.warn("Can't get geometry on point ("+point.getX()+","+point.getY(), ex);
629
        }
630
        
631
        return geometry;
632
    }
633

    
634
    @Override
635
    public Geometry getGeometryOfVisibleLayers(Point point, FeatureStore store, MapContext mapContext) {
636
        
637
        // Search in the store itself
638
        Geometry geometry = this.getGeometry(point, store, mapContext);
639
        // Search in the store for the layers that are in edit
640
        if(geometry == null){
641
            for( Iterator<FLayer> iterator = mapContext.getLayers().deepiterator(); iterator.hasNext(); ) {
642
                FLayer layer = iterator.next();
643
                if(layer instanceof FLyrVect){
644
                    FLyrVect vectLayer = (FLyrVect) layer;
645
                    if(vectLayer.getFeatureStore()!=store && vectLayer.isEditing()){
646
                        geometry  = this.getGeometry(point, vectLayer.getFeatureStore(), mapContext);
647
                        if(geometry != null){
648
                            break;
649
                        }
650
                    }
651
                }
652
            }
653
        }
654
        // Search in the store for the active layers
655
        if(geometry == null){
656
            FLayer[] activeLayers = mapContext.getLayers().getActives();
657
            for (FLayer activeLayer : activeLayers) {
658
                if(activeLayer instanceof FLyrVect){
659
                    FLyrVect activeVectLayer = (FLyrVect) activeLayer;
660
                    if(activeVectLayer.getFeatureStore()!=store && !activeVectLayer.isEditing()){
661
                        geometry  = this.getGeometry(point, activeVectLayer.getFeatureStore(), mapContext);
662
                        if(geometry != null){
663
                            break;
664
                        }
665
                    }
666
                }
667
            }
668
        }
669
        return geometry;
670
    }
671
    
672
    
673
}