Beispiel #1
0
  /**
   * Load all elements of this type from the TMC LocationCodeList.
   *
   * @param aDirectory the directioy where the location-list is stored.
   * @param aLocationTable the top-level class we are working for
   * @return all elements indexed by LocationCode
   * @throws IOException if we cannot read
   */
  public static NavigableMap<Integer, TMCAdminArea> loadAll(
      final File aDirectory, final TMCLocationTable aLocationTable) throws IOException {
    NavigableMap<Integer, TMCAdminArea> retval =
        new TreeMap<Integer, TMCAdminArea>(new AdminAreaComparator());

    File inFile = new File(aDirectory, "ADMINISTRATIVEAREA.DAT");
    BufferedReader in =
        new BufferedReader(new InputStreamReader(new FileInputStream(inFile), "ISO8859-15"));
    in.readLine(); // header;
    String line = in.readLine();
    while (line != null) {
      String[] split = (line + " ").split(";");
      line = in.readLine();
      int i = 0;
      TMCAdminArea point =
          new TMCAdminArea(
              Integer.parseInt(split[i++]), // CID;
              Integer.parseInt(split[i++]), // TABCD;
              Integer.parseInt(split[i++]), // LCD;
              split[i++].charAt(0), // CLASS;
              Integer.parseInt(split[i++]), // TCD;
              Integer.parseInt(split[i++]), // STCD;
              parseOptionalInteger(split[i++]), // NID;
              parseOptionalInteger(split[i++]), // POL_LCD;
              aLocationTable);
      retval.put(point.getLCD(), point);
    }
    return retval;
  }
Beispiel #2
0
 private void addChildArea(final int aParentArea, final TMCAdminArea aAdminArea) {
   Integer parent = aAdminArea.getPOL_LCD();
   Set<TMCAdminArea> children = myChildAreas.get(parent);
   if (children == null) {
     children = new HashSet<TMCAdminArea>();
     myChildAreas.put(parent, children);
   }
   children.add(aAdminArea);
 }
Beispiel #3
0
 /**
  * Generate osm-entities as a reference for comaprison in an editor like JOSM. These are NOT to be
  * uploaded.
  *
  * @param aOutData where to write to
  * @return the generated entity
  */
 public Entity generateReferenceOSM(final MemoryDataSet aOutData) {
   List<RelationMember> members = new ArrayList<RelationMember>();
   if (myReferenceOSMObject != null) {
     aOutData.addRelation(myReferenceOSMObject);
     return myReferenceOSMObject;
   }
   Relation retval = new Relation((long) (Integer.MIN_VALUE), 1, new Date(), OsmUser.NONE, 0);
   if (getName() != null) {
     retval
         .getTags()
         .add(new Tag("name", getName().getNAME() + " " + getLCD() + " - DO NOT UPLOAD"));
   } else {
     retval.getTags().add(new Tag("name", "TMC Admin Area " + getLCD() + " - DO NOT UPLOAD"));
   }
   retval.getTags().add(new Tag("note", "DO NOT UPLOAD THIS ENTITY! IT IS FOR REFERENCE ONLY."));
   retval
       .getTags()
       .add(
           new Tag(
               "TMC:cid_" + getCID() + ":tabcd_" + getTABCD() + ":LocationCode", "" + getLCD()));
   retval
       .getTags()
       .add(new Tag("TMC:cid_" + getCID() + ":tabcd_" + getTABCD() + ":Class", "" + getCLASS()));
   if (getType() != null) {
     retval
         .getTags()
         .add(
             new Tag(
                 "TMC:cid_" + getCID() + ":tabcd_" + getTABCD() + ":TypeName",
                 getType().getTDESC()));
     retval
         .getTags()
         .add(
             new Tag(
                 "TMC:cid_" + getCID() + ":tabcd_" + getTABCD() + ":TypeName:loc",
                 getType().getTNATDESC()));
   }
   if (getSubType() != null) {
     retval
         .getTags()
         .add(
             new Tag(
                 "TMC:cid_" + getCID() + ":tabcd_" + getTABCD() + ":SubTypeName",
                 getSubType().getTDESC()));
     retval
         .getTags()
         .add(
             new Tag(
                 "TMC:cid_" + getCID() + ":tabcd_" + getTABCD() + ":SubTypeName:loc",
                 getSubType().getTNATDESC()));
   }
   TMCAdminArea area = getLocationTable().getAdminArea(getPOL_LCD());
   if (area != null) {
     String name =
         "TMC:cid_" + getCID() + ":tabcd_" + getTABCD() + ":LocationCode=" + area.getLCD();
     if (area.getName() != null) {
       name += " \"" + area.getName().getNAME() + "\"";
     }
     retval.getTags().add(new Tag("note:TMC:area", "belongs to area \"" + name + "\""));
   }
   // Members
   Set<TMCAdminArea> children = myChildAreas.get(getLCD());
   if (children != null) {
     int i = -1;
     for (TMCAdminArea childArea : children) {
       String childName = "";
       if (childArea.getName() != null) {
         childName = " \"" + childArea.getName().getNAME() + "\"";
       }
       RelationMember childMember =
           new RelationMember(
               i--,
               EntityType.Relation,
               "contains: TMC:cid_"
                   + getCID()
                   + ":tabcd_"
                   + getTABCD()
                   + ":LocationCode="
                   + childArea.getLCD()
                   + childName);
       members.add(childMember);
     }
   }
   retval.getMembers().addAll(members);
   aOutData.addRelation(retval);
   myReferenceOSMObject = retval;
   return retval;
 }