~ubuntu-branches/ubuntu/vivid/mkgmap/vivid

« back to all changes in this revision

Viewing changes to src/uk/me/parabola/mkgmap/reader/osm/POIGeneratorHook.java

  • Committer: Package Import Robot
  • Author(s): Andreas Tille
  • Date: 2014-08-13 22:13:41 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20140813221341-i9dzzjuto2o7hfh6
Tags: 0.0.0+svn3333-1
* New upstream version
  Closes: #745097
* add debian/classpath (thanks for the patch to Manfred Stock
  <manfred.stock+debian@gmail.com>)
  Closes: #741596
* d/copyright: DEP5

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
import java.util.AbstractMap;
17
17
import java.util.ArrayList;
18
18
import java.util.Collections;
19
 
import java.util.HashMap;
20
19
import java.util.HashSet;
 
20
import java.util.IdentityHashMap;
21
21
import java.util.List;
22
22
import java.util.Map;
23
23
import java.util.Map.Entry;
69
69
        private boolean poisToLines = false;
70
70
        
71
71
        /** Name of the bool tag that is set to true if a POI is created from an area */
72
 
        public static final String AREA2POI_TAG = "mkgmap:area2poi";
73
 
        public static final String LINE2POI_TAG = "mkgmap:line2poi";
74
 
        public static final String LINE2POI_TYPE_TAG  = "mkgmap:line2poitype";
 
72
        public static final short AREA2POI_TAG = TagDict.getInstance().xlate("mkgmap:area2poi");
 
73
        public static final short LINE2POI_TAG = TagDict.getInstance().xlate("mkgmap:line2poi");
 
74
        public static final short LINE2POI_TYPE_TAG  = TagDict.getInstance().xlate("mkgmap:line2poitype");
75
75
        
76
76
        public boolean init(ElementSaver saver, EnhancedProperties props) {
77
77
                poisToAreas = props.containsKey("add-pois-to-areas");
175
175
        }
176
176
        
177
177
        private void addPOIsToWays() {
178
 
                Map<Coord, Integer> labelCoords = new HashMap<Coord, Integer>(); 
 
178
                Map<Coord, Integer> labelCoords = new IdentityHashMap<Coord, Integer>(); 
179
179
                
180
180
                // save all coords with one of the placement tags to a map
181
181
                // so that ways use this coord as its labeling point
202
202
                        }
203
203
 
204
204
                        // do not add POIs for polygons created by multipolygon processing
205
 
                        if (w.isBoolTag(MultiPolygonRelation.MP_CREATED_TAG)) {
 
205
                        if (w.tagIsLikeYes(MultiPolygonRelation.MP_CREATED_TAG)) {
206
206
                                if (log.isDebugEnabled())
207
207
                                        log.debug("MP processed: Do not create POI for", w.toTagString());
208
208
                                continue;
210
210
                        
211
211
                        
212
212
                        // check if it is an area
213
 
                        if (w.isClosed()) {
 
213
                        if (w.hasIdenticalEndPoints()) {
214
214
                                if (poisToAreas) {
215
215
                                        addPOItoPolygon(w, labelCoords);
216
216
                                        ways2POI++;
264
264
                saver.addNode(poi);
265
265
        }
266
266
        
 
267
        
267
268
        private int addPOItoLine(Way line) {
268
269
                Node startNode = createPOI(line, line.getPoints().get(0), LINE2POI_TAG);
269
270
                startNode.addTag(LINE2POI_TYPE_TAG,"start");
274
275
                saver.addNode(endNode);
275
276
 
276
277
                int noPOIs = 2;
277
 
                
 
278
                Coord lastPoint = line.getPoints().get(0);
278
279
                if (line.getPoints().size() > 2) {
279
280
                        for (Coord inPoint : line.getPoints().subList(1, line.getPoints().size()-1)) {
 
281
                                if (inPoint.equals(lastPoint)){
 
282
                                        continue;
 
283
                                }
 
284
                                lastPoint = inPoint;
280
285
                                Node innerNode = createPOI(line, inPoint, LINE2POI_TAG);
281
286
                                innerNode.addTag(LINE2POI_TYPE_TAG,"inner");
282
287
                                saver.addNode(innerNode);
284
289
                        }
285
290
                }
286
291
                
287
 
                
288
292
                // calculate the middle of the line
289
293
                Coord prevC = null;
290
294
                double sumDist = 0.0;
309
313
                        } 
310
314
                        remMidDist -= nextDist;
311
315
                }
312
 
 
 
316
                
313
317
                if (midPoint != null) {
314
318
                        Node midNode = createPOI(line, midPoint, LINE2POI_TAG);
315
319
                        midNode.addTag(LINE2POI_TYPE_TAG,"mid");
316
320
                        saver.addNode(midNode);
317
321
                        noPOIs++;
318
322
                }
319
 
 
320
323
                return noPOIs;
321
324
 
322
325
        }
323
326
 
324
 
        private Node createPOI(Element source, Coord poiCoord, String poiTypeTag) {
 
327
        private static Node createPOI(Element source, Coord poiCoord, short poiTypeTagKey) {
325
328
                Node poi = new Node(FakeIdGenerator.makeFakeId(), poiCoord);
326
329
                poi.copyTags(source);
327
330
                poi.deleteTag(MultiPolygonRelation.STYLE_FILTER_TAG);
328
 
                poi.addTag(poiTypeTag, "true");
 
331
                poi.addTag(poiTypeTagKey, "true");
329
332
                if (log.isDebugEnabled()) {
330
333
                        log.debug("Create POI",poi.toTagString(),"from",source.getId(),source.toTagString());
331
334
                }