Examples of Trkseg


Examples of net.sourceforge.gpstools.gpx.Trkseg

            final String trkname = trk.getName();
            message(trkname);
            Trkseg[] segs = trk.getTrkseg();
            final int segCount = segs.length;
            for (int iseg = 0; iseg < segCount; iseg++) {
                Trkseg seg = segs[iseg];
                if (seg.getTrkptCount() < 2) {
                    continue;
                }
                /*
                 * if at least one trkpt has a timestamp we accept only trkpts
                 * with timestamps
                 */
                Trkpt[] pts = seg.getTrkpt();
                List<Trkpt> withTimeStamp = new Vector<Trkpt>(pts.length);
                for (Trkpt pt : pts) {
                    if (pt.getTime() != null) {
                        withTimeStamp.add(pt);
                    }
View Full Code Here

Examples of net.sourceforge.gpstools.gpx.Trkseg

    gpx.setCreator(CREATOR);
    gpx.setMetadata(metadata);

    Trk track = new Trk();
    track.setName(recurso);
    Trkseg segmento = new Trkseg();
    for (HistoricoGPS hist : historico) {
      Geometry geom = hist.getGeom();
      if (geom != null && geom.getCentroid().getX() != 0.0d
          && geom.getCentroid().getY() != 0.0d) {

        Trkpt punto = new Trkpt();
        punto.setLon(BigDecimal.valueOf(geom.getCentroid().getX()));
        punto.setLat(BigDecimal.valueOf(geom.getCentroid().getY()));
        punto.setTime(hist.getMarcaTemporal());
        punto.setName(recurso
            + " "
            + DateFormat.getDateInstance(DateFormat.SHORT, LOCALE)
                .format(new Date(hist.getMarcaTemporal()
                    .getTime()))
            + " "
            + DateFormat.getTimeInstance(DateFormat.MEDIUM, LOCALE)
                .format(new Date(hist.getMarcaTemporal()
                    .getTime())));

        segmento.addTrkpt(punto);
      }

    }
    track.addTrkseg(segmento);
    gpx.addTrk(track);
View Full Code Here

Examples of net.sourceforge.gpstools.gpx.Trkseg

        // Start by reading the file and analyzing it contents
        Gpx gpx = GPSDings.readGPX(new FileInputStream(file));
        TrackAnalyzer analyzer = new TrackAnalyzer();
        analyzer.addAllTracks(gpx);
        // The garmin GPX running data contains only one track containing one segment
        Trkseg track = gpx.getTrk(0).getTrkseg(0);

        // Start a new transaction
        Transaction tx = graphDb.beginTx();
        // Contains the record that was added previously (in order to create a relation between the new and the previous node)
        SpatialDatabaseRecord fromrecord = null;

        // Iterate all points
        for (int i = 0; i < track.getTrkptCount(); i++) {

            // Create a new coordinate for this point
            Coordinate to = new Coordinate(track.getTrkpt(i).getLon().doubleValue(),track.getTrkpt(i).getLat().doubleValue());

            // Check whether we can find a node from which is located within a distance of 20 meters
            List<GeoPipeFlow> closests = GeoPipeline.startNearestNeighborLatLonSearch(runningLayer, to, 0.02).sort("OrthodromicDistance").getMin("OrthodromicDistance").toList();
            SpatialDatabaseRecord torecord = null;

            // If first time, we add all nodes. Otherwise, we check whether we find a node that is close enough to the current location
            if (!firsttime && (closests.size() == 1)) {
                // Retrieve the node
                System.out.println("Using existing: " + closests.get(0).getProperty("OrthodromicDistance"));
                torecord = closests.get(0).getRecord();
                // Recalculate average speed
                double previousspeed  =  (Double)torecord.getProperty("speed");
                int previousoccurences =  (Integer)torecord.getProperty("occurences");
                double currentspeed = analyzer.getHorizontalSpeed(track.getTrkpt(i).getTime());
                double denormalizespeed = previousspeed * previousoccurences;
                double newspeed = ((denormalizespeed + currentspeed) / (previousoccurences + 1));
                // Update the data accordingly
                torecord.setProperty("speed",newspeed);
                torecord.setProperty("occurences",previousoccurences+1);
            }
            else {
                // New node, add it
                torecord = runningLayer.add(runningLayer.getGeometryFactory().createPoint(to));
                // Set the data accordingly
                torecord.setProperty("speed", analyzer.getHorizontalSpeed(track.getTrkpt(i).getTime()));
                torecord.setProperty("occurences", 1);
            }

            // If a previous node is available (and they are not identical), add a directed relationship between both
            if (fromrecord != null && (!fromrecord.equals(torecord)))  {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.