Package org.openstreetmap.josm.data.osm

Examples of org.openstreetmap.josm.data.osm.OsmPrimitive


   *
   * @param geometry
   * @return
   */
  public static OsmPrimitive wktToOsmPrimitive(String geometry) {
    OsmPrimitive resultado = null;

    if (geometry != null) {
      log.trace("Vamos a convertir " + geometry);
      String[] componentes = StringUtils.split(geometry, "(");

View Full Code Here


    r.clearErrors();

    Way fromWay = null;
    Way toWay = null;
    OsmPrimitive via = null;

    /* find the "from", "via" and "to" elements */
    for (RelationMember m : r.members) {
      // if(restrictionDebug)
      // System.out.println("member " + m.member + " selected " +
View Full Code Here

   *            If the object in the iterator is not in the list, nothing will
   *            be changed on it.
   */
  private void cleanIterator(final Iterator<? extends OsmPrimitive> it,
      final Collection<OsmPrimitive> processed) {
    final OsmPrimitive osm = it.next();
    if (!processed.remove(osm))
      return;
    osm.modified = false;
    if (osm.deleted)
      it.remove();
View Full Code Here

     * @param predicate the returned object has to fulfill certain properties.
     */
    public final List<OsmPrimitive> getNearestNodesOrWays(Point p,
            Collection<OsmPrimitive> ignore, Predicate<OsmPrimitive> predicate) {
        List<OsmPrimitive> nearestList = Collections.emptyList();
        OsmPrimitive osm = getNearestNodeOrWay(p, predicate, false);

        if (osm != null) {
            if (osm instanceof Node) {
                nearestList = new ArrayList<OsmPrimitive>(getNearestNodes(p, predicate));
            } else if (osm instanceof Way) {
View Full Code Here

        if (use_selected && ds!=null) {
            sel = ds.getSelected();
        } else {
            sel = null;
        }
        OsmPrimitive osm = getNearestNode(p, predicate, use_selected, sel);

        if (isPrecedenceNode((Node)osm, p, use_selected)) return osm;
        WaySegment ws;
        if (use_selected) {
            ws = getNearestWaySegment(p, predicate, use_selected, sel);
View Full Code Here

        waysUsedInRelations = new HashSet<>();
        for (Relation r : Main.main.getCurrentDataSet().getRelations()) {
            if (r.isUsable()) {
                for (RelationMember m : r.getMembers()) {
                    if (r.isMultipolygon() || WHITELIST.contains(m.getRole())) {
                        OsmPrimitive member = m.getMember();
                        if (member instanceof Way && member.isUsable() && !member.isTagged()) {
                            waysUsedInRelations.add((Way)member);
                        }
                    }
                }
            }
View Full Code Here

            // Used to check distance
            Set<OsmPrimitive> houses = new HashSet<>();
            Set<Way> street = new HashSet<>();
            for (RelationMember m : r.getMembers()) {
                String role = m.getRole();
                OsmPrimitive p = m.getMember();
                if ("house".equals(role)) {
                    houses.add(p);
                    String number = p.get(ADDR_HOUSE_NUMBER);
                    if (number != null) {
                        number = number.trim().toUpperCase();
                        List<OsmPrimitive> list = map.get(number);
                        if (list == null) {
                            map.put(number, list = new ArrayList<>());
                        }
                        list.add(p);
                    }
                } else if ("street".equals(role)) {
                    if (p instanceof Way) {
                        street.add((Way) p);
                    }
                    if (relationName != null && p.hasKey("name") && !relationName.equals(p.get("name"))) {
                        if (wrongStreetNames.isEmpty()) {
                            wrongStreetNames.add(r);
                        }
                        wrongStreetNames.add(p);
                    }
View Full Code Here

        // Warm about deleted primitives
        final Set<PrimitiveId> del = new HashSet<>();
        DataSet ds = Main.main.getCurrentDataSet();
        for (PrimitiveId id : ids) {
            OsmPrimitive osm = ds.getPrimitiveById(id);
            if (osm != null && osm.isDeleted()) {
                del.add(id);
            }
        }
        if (!del.isEmpty())
            GuiHelper.runInEDTAndWait(new Runnable() {
View Full Code Here

            Relation relation = (Relation) externalIdMap.get(
                    new SimplePrimitiveId(externalRelationId, OsmPrimitiveType.RELATION)
            );
            List<RelationMember> relationMembers = new ArrayList<>();
            for (RelationMemberData rm : relations.get(externalRelationId)) {
                OsmPrimitive primitive = null;

                // lookup the member from the map of already created primitives
                primitive = externalIdMap.get(new SimplePrimitiveId(rm.getMemberId(), rm.getMemberType()));

                if (primitive == null) {
                    if (rm.getMemberId() <= 0)
                        // relation member refers to a primitive with a negative id which was not
                        // found in the data. This is always a data integrity problem and we abort
                        // with an exception
                        //
                        throw new IllegalDataException(
                                tr("Relation with external id ''{0}'' refers to a missing primitive with external id ''{1}''.",
                                        externalRelationId,
                                        rm.getMemberId()));

                    // member refers to OSM primitive which was not present in the parsed data
                    // -> create a new incomplete primitive and add it to the dataset
                    //
                    primitive = ds.getPrimitiveById(rm.getMemberId(), rm.getMemberType());
                    if (primitive == null) {
                        switch (rm.getMemberType()) {
                        case NODE:
                            primitive = new Node(rm.getMemberId()); break;
                        case WAY:
                            primitive = new Way(rm.getMemberId()); break;
                        case RELATION:
                            primitive = new Relation(rm.getMemberId()); break;
                        default: throw new AssertionError(); // can't happen
                        }

                        ds.addPrimitive(primitive);
                        externalIdMap.put(new SimplePrimitiveId(rm.getMemberId(), rm.getMemberType()), primitive);
                    }
                }
                if (primitive.isDeleted()) {
                    Main.info(tr("Deleted member {0} is used by relation {1}", primitive.getId(), relation.getId()));
                } else {
                    relationMembers.add(new RelationMember(rm.getRole(), primitive));
                }
            }
            relation.setMembers(relationMembers);
View Full Code Here

                Stack<OsmPrimitive> toCheck = new Stack<>();
                toCheck.addAll(getPrimitivesToCheckForParents());
                Set<OsmPrimitive> checked = new HashSet<>();
                while(!toCheck.isEmpty()) {
                    if (canceled) return;
                    OsmPrimitive current = toCheck.pop();
                    synchronized(this) {
                        reader = new OsmServerBackreferenceReader(current);
                    }
                    getProgressMonitor().subTask(tr("Reading parents of ''{0}''", current.getDisplayName(DefaultNameFormatter.getInstance())));
                    DataSet ds = reader.parseOsm(getProgressMonitor().createSubTaskMonitor(1, false));
                    synchronized(this) {
                        reader = null;
                    }
                    checked.add(current);
                    getProgressMonitor().subTask(tr("Checking for deleted parents in the local dataset"));
                    for (OsmPrimitive p: ds.allPrimitives()) {
                        if (canceled) return;
                        OsmPrimitive myDeletedParent = layer.data.getPrimitiveById(p);
                        // our local dataset includes a deleted parent of a primitive we want
                        // to delete. Include this parent in the collection of uploaded primitives
                        //
                        if (myDeletedParent != null && myDeletedParent.isDeleted()) {
                            if (!toUpload.contains(myDeletedParent)) {
                                toUpload.add(myDeletedParent);
                            }
                            if (!checked.contains(myDeletedParent)) {
                                toCheck.push(myDeletedParent);
View Full Code Here

TOP

Related Classes of org.openstreetmap.josm.data.osm.OsmPrimitive

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.