Package processing.data

Examples of processing.data.XML


  }

  public void loadRSSGeoLocations() {
    // Load RSS feed
    String url = "http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-M5.xml";
    XML rss = loadXML(url);
    // Get all items
    XML[] itemXML = rss.getChildren("channel/item");
    for (int i = 0; i < itemXML.length; i++) {
      // Adds lat,lon as locations for each item
      XML latXML = itemXML[i].getChild("geo:lat");
      XML lonXML = itemXML[i].getChild("geo:long");
      if (latXML != null && latXML.getContent() != null) {
        float lat = Float.valueOf(latXML.getContent());
        float lon = Float.valueOf(lonXML.getContent());

        rssGeoLocations.add(new Location(lat, lon));
      }
    }
  }
View Full Code Here


    List<TrackPoint> trackPoints = new ArrayList<TrackPoint>();
    Calendar prevTime = null;
    Location prevLocation = null;

    // Load GPX file
    XML gpx = p.loadXML(gpxFilename);
    // Get all track points
    XML[] itemXML = gpx.getChildren("trk/trkseg/trkpt");
    for (int i = 0; i < itemXML.length; i++) {
      // Creates location for track point
      float lat = itemXML[i].getFloat("lat");
      float lon = itemXML[i].getFloat("lon");
      Location location = new Location(lat, lon);
View Full Code Here

   */
  public static List<Feature> loadData(PApplet p, String gpxFilename) {
    List<Feature> trackFeatures = new ArrayList<Feature>();

    // Load GPX file
    XML gpx = p.loadXML(gpxFilename);

    // TODO Handle multiple features in one GPX file
   
    // Create track with all track points
    ShapeFeature trackFeature = new ShapeFeature(FeatureType.LINES);
    List<String> trackPointTimes = new ArrayList<String>();

    XML[] itemXML = gpx.getChildren("trk/trkseg/trkpt");
    for (int i = 0; i < itemXML.length; i++) {
      XML trackPoint = itemXML[i];

      // Adds location for track point
      float lat = trackPoint.getFloat("lat");
      float lon = trackPoint.getFloat("lon");
      Location location = new Location(lat, lon);
      trackFeature.addLocation(location);

      XML trackPointTime = trackPoint.getChild("time");
      if (trackPointTime != null) {
        trackPointTimes.add(trackPointTime.getContent());
      }
    }

    // Add name for whole track as property
    XML nameXMLElement = gpx.getChild("trk/name");
    if (nameXMLElement != null) {
      trackFeature.addProperty("name", nameXMLElement.getContent());
    }
    // Add (single) time for whole track as property
    XML timeXMLElement = gpx.getChild("trk/time");
    if (timeXMLElement != null) {
      trackFeature.addProperty("time", timeXMLElement.getContent());
    }
    // Add times of all track points as property
    if (!trackPointTimes.isEmpty() && trackFeature.getLocations().size() == trackPointTimes.size()) {
      trackFeature.addProperty("trackPointTimes", trackPointTimes);
    }
View Full Code Here

   * @return A list of geo features.
   */
  public static List<Feature> loadData(PApplet p, String fileName) {
    List<Feature> features = new ArrayList<Feature>();

    XML rss = p.loadXML(fileName);
    // Get all items
    XML[] itemXML = rss.getChildren("channel/item");
    for (int i = 0; i < itemXML.length; i++) {
      // Sets lat,lon as locations for each item
      XML latXML = itemXML[i].getChild("geo:lat");
      XML lonXML = itemXML[i].getChild("geo:long");
      if (latXML != null && latXML.getContent() != null) {
        float lat = Float.valueOf(latXML.getContent());
        float lon = Float.valueOf(lonXML.getContent());

        Location location = new Location(lat, lon);
        PointFeature pointFeature = new PointFeature(location);
        features.add(pointFeature);

        // Sets title if existing
        XML titleXML = itemXML[i].getChild("title");
        if (titleXML != null && titleXML.getContent() != null) {
          pointFeature.putProperty("title", titleXML.getContent());
        }
      }
    }

    return features;
View Full Code Here

   * @return A list of geo features.
   */
  public static List<Feature> loadDataGeoRSS(PApplet p, String fileName) {
    List<Feature> features = new ArrayList<Feature>();

    XML rss = p.loadXML(fileName);
    // Get all items
    XML[] itemXML = rss.getChildren("entry");
    for (int i = 0; i < itemXML.length; i++) {
      // Sets lat,lon as locations for each item
      XML pointXML = itemXML[i].getChild("georss:point");
      if (pointXML != null && pointXML.getContent() != null) {
        String point = pointXML.getContent();
        String[] latLon = point.split(" ");
        float lat = Float.valueOf(latLon[0]);
        float lon = Float.valueOf(latLon[1]);

        Location location = new Location(lat, lon);
        PointFeature pointFeature = new PointFeature(location);
        features.add(pointFeature);

        // Sets title if existing
        XML titleXML = itemXML[i].getChild("title");
        if (titleXML != null && titleXML.getContent() != null) {
          pointFeature.putProperty("title", titleXML.getContent());
        }

        // Sets date if existing
        XML dateXML = itemXML[i].getChild("dc:date");
        if (dateXML != null && dateXML.getContent() != null) {
          pointFeature.putProperty("date", dateXML.getContent());
        }

        // Sets magnitude if existing
        XML[] catXML = itemXML[i].getChildren("category");
        for (int c = 0; c < catXML.length; c++) {
View Full Code Here

   */
  public static List<Feature> loadData(PApplet p, String gpxFilename) {
    List<Feature> trackFeatures = new ArrayList<Feature>();

    // Load GPX file
    XML gpx = p.loadXML(gpxFilename);

    Calendar prevTime = null;
    Location prevLocation = null;

    // Create track with all track points
    ShapeFeature trackFeature = new ShapeFeature(FeatureType.LINES);
    List<Double> speedList = new ArrayList<Double>();

    XML[] itemXML = gpx.getChildren("trk/trkseg/trkpt");
    for (int i = 0; i < itemXML.length; i++) {

      // Adds location for track point
      float lat = itemXML[i].getFloat("lat");
      float lon = itemXML[i].getFloat("lon");
View Full Code Here

   *
   * @param filename the path to the XML file
   */
  private void loadSettings(String filename) {
    // parse XML file
    XML xml = p5parent.loadXML(filename);
    setServer(xml.getChild("server/ip").getContent());
    setPort(xml.getChild("server/port").getIntContent());
    setID(xml.getChild("id").getIntContent());

    XML name = xml.getChild("name");
    if (name != null) {
      setClientName(name.getContent());
    }


    XML asynch = xml.getChild("asynchronous");
    if (asynch != null) {
      String a = asynch.getContent();
      asynchronous = Boolean.parseBoolean(a);
      if (asynchronous) {
        XML receive = xml.getChild("asynchreceive");
        if (receive != null) {
          String r = receive.getContent();
          asynchreceive = Boolean.parseBoolean(r);
        }
      }
    }



    String v = xml.getChild("verbose").getContent();
    VERBOSE = Boolean.parseBoolean(v);

    // Implement name
    if (!asynchronous) {
      int w = xml.getChild("local_dimensions/width").getIntContent();
      int h = xml.getChild("local_dimensions/height").getIntContent();
      setLocalDimensions(w,h);

      int x = xml.getChild("local_location/x").getIntContent();
      int y = xml.getChild("local_location/y").getIntContent();
      setOffsets(x,y);

      int mw = xml.getChild("master_dimensions/width").getIntContent();
      int mh = xml.getChild("master_dimensions/height").getIntContent();
      setLocalDimensions(w,h);

      XML offset = xml.getChild("offset_window");
      if (offset != null) {
        offsetWindow = Boolean.parseBoolean(offset.getContent());
      }

      XML simxml = xml.getChild("simulation");
      if (simxml != null) {
        simulation = Boolean.parseBoolean(simxml.getContent());
        simFPS = simxml.getInt("fps");
        if (simFPS < 1) simFPS = 30;
      }

      setMasterDimensions(mw,mh);

View Full Code Here

TOP

Related Classes of processing.data.XML

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.