예제 #1
0
 /**
  * Gets be called on opening tags like: <tag> Can provide attribute(s), when xml was like: <tag
  * attribute="attributeValue">
  */
 @Override
 public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
     throws SAXException {
   if (localName.equalsIgnoreCase("kml")) {
     this.in_kmltag = true;
   } else if (localName.equalsIgnoreCase("Placemark")) {
     this.in_placemarktag = true;
     navigationDataSet.setCurrentPlacemark(new Placemark());
   } else if (localName.equalsIgnoreCase("name")) {
     this.in_nametag = true;
   } else if (localName.equalsIgnoreCase("description")) {
     this.in_descriptiontag = true;
   } else if (localName.equalsIgnoreCase("point")) {
     this.in_pointtag = true;
   } else if (localName.equalsIgnoreCase("country")) {
     this.in_conutry = true;
     this.is_conutry = true;
   } else if (localName.equalsIgnoreCase("coordinates")) {
     buffer = new StringBuffer();
     this.in_coordinatestag = true;
   }
 }
예제 #2
0
  /** Gets be called on the following structure: <tag>characters</tag> */
  @Override
  public void characters(char ch[], int start, int length) {
    if (this.in_nametag) {

      if (navigationDataSet.getCurrentPlacemark() == null)
        navigationDataSet.setCurrentPlacemark(new Placemark());

      navigationDataSet.getCurrentPlacemark().setTitle(new String(ch, start, length));

    } else if (this.in_descriptiontag) {

      if (navigationDataSet.getCurrentPlacemark() == null)
        navigationDataSet.setCurrentPlacemark(new Placemark());

      navigationDataSet.getCurrentPlacemark().setDescription(new String(ch, start, length));
    } else if (this.in_conutry) {

      if (navigationDataSet.getCurrentPlacemark() == null)
        navigationDataSet.setCurrentPlacemark(new Placemark());

      String temp_country = new String(ch, start, length);
      navigationDataSet.getCurrentPlacemark().setCountry(true);
      if (temp_country.compareTo(last_country) != 0) last_country = temp_country;

    } else if (this.in_coordinatestag) {

      if (navigationDataSet.getCurrentPlacemark() == null)
        navigationDataSet.setCurrentPlacemark(new Placemark());

      navigationDataSet.getCurrentPlacemark().setCoordinates(new String(ch, start, length));
      navigationDataSet.getCurrentPlacemark().setCountry(last_country);

      navigationDataSet.addCurrentPlacemark();

      buffer.append(ch, start, length);
    }
  }