Esempio n. 1
0
  private void process(OsmRelation relation) {
    boolean hasChildRelations = false;
    TLongList childRelationMembers = new TLongArrayList();
    for (OsmRelationMember member : OsmModelUtil.membersAsList(relation)) {
      if (member.getType() == EntityType.Relation) {
        hasChildRelations = true;
        idsIsChildRelation.add(member.getId());
        childRelationMembers.add(member.getId());
        if (storeSimpleRelations) {
          idsSimpleRelations.remove(member.getId());
        }
      }
    }
    long id = relation.getId();
    if (hasChildRelations) {
      idsHasChildRelations.add(id);
      if (!graph.getNodes().contains(id)) {
        graph.addNode(id);
      }

      TLongIterator iterator = childRelationMembers.iterator();
      while (iterator.hasNext()) {
        long member = iterator.next();
        if (!graph.getNodes().contains(member)) {
          graph.addNode(member);
        }
        graph.addEdge(id, member);
      }
    } else {
      if (storeSimpleRelations && !idsIsChildRelation.contains(id)) {
        idsSimpleRelations.add(id);
      }
      numNoChildren++;
    }
  }
Esempio n. 2
0
 /** @return null when not found */
 public TLongList listLabelIds(long bukmak2_id) {
   TLongList res = null;
   Cursor cursor =
       helper
           .getReadableDatabase()
           .rawQuery(
               "select "
                   + Db.TABEL_Bukmak2_Label
                   + "."
                   + Db.Bukmak2_Label.label_id
                   + " from "
                   + Db.TABEL_Bukmak2_Label
                   + " where "
                   + Db.TABEL_Bukmak2_Label
                   + "."
                   + Db.Bukmak2_Label.bukmak2_id
                   + "=?",
               new String[] {
                 String.valueOf(bukmak2_id)
               }); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$//$NON-NLS-6$
   try {
     int col_label_id = cursor.getColumnIndexOrThrow(Db.Bukmak2_Label.label_id);
     while (cursor.moveToNext()) {
       if (res == null) res = new TLongArrayList();
       res.add(cursor.getLong(col_label_id));
     }
   } finally {
     cursor.close();
   }
   return res;
 }
Esempio n. 3
0
  protected void readNodes(XMLStreamReader parser) throws XMLStreamException {
    int event = parser.getEventType();
    while (event != XMLStreamConstants.END_DOCUMENT && parser.getLocalName().equals("nd")) {
      if (event == XMLStreamConstants.START_ELEMENT) {
        // read node reference
        String ref = parser.getAttributeValue(null, "ref");
        nodes.add(Long.parseLong(ref));
      }

      event = parser.nextTag();
    }
  }