IBP Index API v2.0

Con esta API se obtiene toda la información del análisis IBP index.

El proceso se inicia con el envío del archivo de track a nuestro servidor, y este devuelve un objeto en JSON con todos los datos.
Para poder utilizar la API, obtenga una key, y lea los ejemplos y la documentación de esta página.

Ejemplo de solicitud con PHP CURL

class IBP {
   var $filename; //Source filename
   var $ibp; //Resoult: JSON Object)
   function IBP($filename = false){ //Constructor
	   if(!empty($filename)) $this->getIBP($filename);
   }
   function getIBP($filename) {
	   if(file_exists($filename)) {
            
            //Post fields
            $post_data = array();
            $ch = curl_init(); 
            if ((version_compare(PHP_VERSION, '5.5') >= 0)) {
                $post_data['file'] = new CURLFile($filename);
                curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
            } else {
                $post_data['file'] = "@".$filename;
            }
            $post_data['key'] = 'yourapikey';  // Your api key
            //Curl connection
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, "https://www.ibpindex.com/api/" );  // or "https://www.ibpindex.com/api/index.php"
            curl_setopt($ch, CURLOPT_POST, 1 );
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            $postResult = curl_exec($ch); //return result
            if (curl_errno($ch)) {
               die(curl_error($ch)); //this stops the execution under a Curl failure
            }
            curl_close($ch); //close connection
            $this->ibp = $postResult;
            return $postResult; 
	   }
   }
}
# usage: $ibp = new IBP('path/to/file.gpx');
$ibp = new IBP('api_demo_track.gpx'); 
$ibpindex_json = $ibp->ibp;

Ejemplo de solicitud con AJAX + Jquery

    <form enctype="multipart/form-data" id="formuploadajax" method="post">
        API key: <input type="text" name="key" placeholder="yourapikey" value="yourapikey">
        <br /><br />
        <input  type="file" id="file" name="file"/>
        <br /><br />
        <input type="submit" value="Upload file"/>
    </form><br />
    <div id="obtain"></div>
    
    <script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
    <script>
    $(function(){
        $("#formuploadajax").on("submit", function(e){
            e.preventDefault();
            var f = $(this);
            var formData = new FormData(document.getElementById("formuploadajax"));
            $.ajax({
                url: "https://www.ibpindex.com/api/",  // or "https://www.ibpindex.com/api/index.php"
                type: "post",
                dataType: "json",
                data: formData,
                cache: false,
                contentType: false,
	            processData: false
            })
                .done(function(javascript_json){
					weobtain = 'Reference: ' + javascript_json['reference'] + 
					'File name: ' + javascript_json['filename'] +
					'IBP: ' + javascript_json['bicycle']['ibp'] +
					'Accumulated climb: ' + javascript_json['bicycle']['accuclimb'] +
					'Total stop time: ' + javascript_json['bicycle']['totalstoptime'] +
					'Stopped time (first): ' + javascript_json['bicycle']['stops'][0]['stoppedtime']
					document.getElementById('obtain').innerHTML = weobtain;
                });
        });
    });
    </script>

Ejemplo 1

Ejemplo para extraer el IBP index y los datos de una ruta de una modalidad concreta (ciclismo, senderismo, running).
Queremos extraer el IBP index de una ruta de Bicicleta (BYC) y algunos datos que nos interesan como... el IBP index, el acrónimo de la modalidad, la distancia total, el desnivel acumulado, la primera parada desde la salida con su duración, la segunda parada desde la salida con su duración.

Extracción de datos para este ejemplo

<?php $someArray = json_decode($ibpindex_json, true) ?>
IBP: <?php echo $someArray["bicycle"]["ibp"] ?><br>
Modality: <?php echo $someArray["bicycle"]["acronym"] ?><br>
Total Distance: <?php echo $someArray["bicycle"]["totlengthkm"] ?><br>
Accumulated climb: <?php echo $someArray["bicycle"]["accuclimb"] ?><br>
First stop from the start: <?php echo $someArray["bicycle"]["stops"][0]["stopdistancekm"] ?><br>
First stopped time: <?php echo $someArray["bicycle"]["stops"][0]["stoppedtime"] ?><br>
Second stop from the start: <?php echo $someArray["bicycle"]["stops"][0]["stopdistancekm"] ?><br>
Second stopped time: <?php echo $someArray["bicycle"]["stops"][0]["stoppedtime"] ?><br>

Extracción de datos para este ejemplo

<script type="text/javascript">
    javascript_json = <?php echo $ibpindex_json ?>
    document.write("IBP: " + javascript_json["bicycle"]["ibp"] + "<br>");
    document.write("Modality: " + javascript_json["bicycle"]["acronym"] + "<br>");
    document.write("Total Distance: " + javascript_json["bicycle"]["totlengthkm"] + "<br>");
    document.write("Accumulated climb: " + javascript_json["bicycle"]["accuclimb"] + "<br>");
    document.write("First stop from the start: " + javascript_json["bicycle"]["stops"][0]["stopdistancekm"] + "<br>");
    document.write("First stopped time: " + javascript_json["bicycle"]["stops"][0]["stoppedtime"] + "<br>");
    document.write("Second stop from the start: " + javascript_json["bicycle"]["stops"][1]["stopdistancekm"] + "<br>");
    document.write("Second stopped time: " + javascript_json["bicycle"]["stops"][1]["stoppedtime"] + "<br>");
</script>

Resultado

IBP: 140
Modality: BYC
Total Distance: 116.689
Accumulated climb: 2323.39
First stop from the start: 30.362
First stopped time: 0:01:15
Second stop from the start: 30.642
Second stopped time: 0:03:06

Ejemplo 2

Ejemplo para extraer el IBP index y los datos de una ruta desconociendo su modalidad (ciclismo, senderismo, running).
Queremos extraer el IBP index de una ruta usando la modalidad detectada por el sistema y algunos datos que nos interesan como... el IBP index, el acrónimo de la modalidad, la distancia total, el desnivel acumulado, la primera parada desde la salida con su duración, la segunda parada desde la salida con su duración.

Extracción de datos para este ejemplo en PHP

<?php $someArray = json_decode($ibpindex_json, true) ?>
IBP: <?php echo $someArray[$someArray["detectedmodality"]]["ibp"] ?><br>
Modality: <?php echo $someArray[$someArray["detectedmodality"]]["acronym"] ?><br>
Total Distance: <?php echo $someArray[$someArray["detectedmodality"]]["totlengthkm"] ?><br>
Accumulated climb: <?php echo $someArray[$someArray["detectedmodality"]]["accuclimb"] ?><br>
First stop from the start: <?php echo $someArray[$someArray["detectedmodality"]]["stops"][0]["stopdistancekm"] ?><br>
First stopped time: <?php echo $someArray[$someArray["detectedmodality"]]["stops"][0]["stoppedtime"] ?><br>
Second stop from the start: <?php echo $someArray[$someArray["detectedmodality"]]["stops"][0]["stopdistancekm"] ?><br>
Second stopped time: <?php echo $someArray[$someArray["detectedmodality"]]["stops"][0]["stoppedtime"] ?><br>

Extracción de datos para este ejemplo en JavaScript

<script type="text/javascript">
    javascript_json = <?php echo $ibpindex_json ?>
    document.write("IBP: " + javascript_json[javascript_json["detectedmodality"]]["ibp"] + "<br>");
    document.write("Modality: " + javascript_json[javascript_json["detectedmodality"]]["acronym"] + "<br>");
    document.write("Total Distance: " + javascript_json[javascript_json["detectedmodality"]]["totlengthkm"] + "<br>");
    document.write("Accumulated climb: " + javascript_json[javascript_json["detectedmodality"]]["accuclimb"] + "<br>");
    document.write("First stop from the start: " + javascript_json[javascript_json["detectedmodality"]]["stops"][0]["stopdistancekm"] + "<br>");
    document.write("First stopped time: " + javascript_json[javascript_json["detectedmodality"]]["stops"][0]["stoppedtime"] + "<br>");
    document.write("Second stop from the start: " + javascript_json[javascript_json["detectedmodality"]]["stops"][1]["stopdistancekm"] + "<br>");
    document.write("Second stopped time: " + javascript_json[javascript_json["detectedmodality"]]["stops"][1]["stoppedtime"] + "<br>");
</script>

Resultado

IBP: 140
Modality: BYC
Total Distance: 116.689
Accumulated climb: 2323.39
First stop from the start: 30.362
First stopped time: 0:01:15
Second stop from the start: 30.642
Second stopped time: 0:03:06

Otras opciones

No dudes en contactar con nosotros para cualquier duda o aclaración que necesites,
queremos ayudarte a conseguir la mejor adaptación que requiera tu web o aplicación.

API v2.0 reference

 { 
     "error": "", Error message, or observations
     "reference": "36647160175900", Analysis  reference
     "filename": "route_track_file.gpx", File name
     "trackpoints": "4422", Number of points
     "trackpointscad": "26.39", Points cadence
     "significantpoints": "2057", Significant points
     "signipointscad": "56.73", Significant points cadence
     "porcsignipoints": "46.56", Significant points percentage
     "detectedmodality": "bicycle", Detected modality
     "bicycle": { Bicycle modality
         "ibp": "140", IBP index
         "acronym": "BYC", Modality acronym (BYC = bicycle, HKG = hiking, RNG = running)
         "ibpfit": "64", IBP Fit  (9999 Not enought comparison elements)
         "maxlopefilter": "30", Maximum slope filter
         "totlengthkm": "116.689", Total length
         "analyzedlengthkm": "116.689", Analyzed length
         "accuclimb": "2323.39", Accumulated climb
         "accudescent": "2300.2", Accumulated descent
         "maxheight": "2414.68", Maximum height
         "minheight": "677.94", Minimal height
         "startheight": "678.43", Start height
         "finishheight": "694.37", End height
         "climbpkm": "19.91", Positive climb difference per Km
         "descentpkm": "19.71", Negative descent difference per Km
         "climbrate": "4.98", Climb rate
         "descentrate": "4.61", Descent rate
         "dirchanpkm": "6.99", Direction changes per Km
         "dirchan5gkm": "5.19", Direction changes >5º per Km
         "totstraightkm": "18.86", Accumulated straight stretches
         "totstraightpkm": "161.63", Straight stretches per Km
         "totslopechg": "11", Penalizables slope changes
         "totslopepkm": "0.094", Penalizables slope changes per Km
         "errorpoints": "32", Aberrant points
         "pererrorpoints": "0.72", Aberrant points percentage
         "linealdistance": "0.011", Lineal distance
         "averagespeed": "18.62", Average speed in movement 
         "maxspeed": "63.89", Maximum held speed
         "movementtime": "6:16:01", Time in movement
         "stoptime": "0:17:43", Stopped time
         "totaltime": "6:33:44", Total time
         "totalspeed": "17.78", Total speed average
         "totdescdistkm": "49.924", Total descents distance
         "pertotdesc": "42.78", Descents distance percentage
         "totplaindistkm": "20.113", Total plain distance
         "pertotalplain": "17.24", Plain distance percentage
         "totclimbdistkm": "46.652", Total climb distance
         "pertotclimb": "39.98", Climb distance percentage
         "totclimb30_55km": "0", Climbs between 30% and 55% (only HKG and RNG)
         "totclimb15_30km": "0.287", Climbs between 15% and 30%
         "totclimb10_15km": "2.462", Climbs between 10% and 15%
         "totclimb5_10km": "9.345", Climbs between 5% and 10%
         "totclimb1_5km": "6.937", Climbs between 1% and 5%
         "totclimb1_1km": "6.781", Plain between -1% and 1%
         "totclimb5_1km": "6.037", Descents between -1% and -5%
         "totclimb10_5km": "8.161", Descents between -5% and -10%
         "totclimb15_10km": "2.728", Descents between -10% and -15%
         "totclimb30_15km": "0.695", Descents between -15% and -30%
         "totclimb55_30km": "0", Descents between -30% and -55% (only HKG and RNG)
         "perclimb30_55km": "0", Percent climbs between 30% and 55% (only HKG and RNG)
         "perclimb15_30km": "0.66", Percent climbs between 15% and 30%
         "perclimb10_15km": "5.67", Percent climbs between 10% and 15%
         "perclimb5_10km": "21.52", Percent climbs between 5% and 10%
         "perclimb1_5km": "15.97", Percent climbs between 1% and 5%
         "perclimb1_1km": "15.61", Percent plain between -1% and 1%
         "perclimb5_1km": "13.9", Percent descents between -1% and -5%
         "perclimb10_5km": "18.79", Percent descents between -5% and -10%
         "perclimb15_10km": "6.28", Percent descents between -10% and -15%
         "perclimb30_15km": "1.6", Percent descents between -15% and -30%
         "perclimb55_30km": "0", Percent descents between -30% and -55% (only HKG and RNG)
         "speedclimb30_55km": "0", Time climbs between 30% and 55% (only HKG and RNG)
         "speedclimb15_30km": "7.84", Time climbs between 15% and 30%
         "speedclimb10_15km": "8.82", Time climbs between 10% and 15%
         "speedclimb5_10km": "10.93", Time climbs between 5% and 10%
         "speedclimb1_5km": "14.58", Time climbs between 1% and 5%
         "speedclimb1_1km": "18.03", Time plain between -1% and 1%
         "speedclimb5_1km": "20.16", Time descents between -1% and -5%
         "speedclimb10_5km": "21.3", Time descents between -5% and -10%
         "speedclimb15_10km": "19.29", Time descents between -10% and -15%
         "speedclimb30_15km": "14.21", Time descents between -15% and -30%
         "speedclimb55_30km": "0", Time descents between -30% and -55% (only HKG and RNG)
         "descenttime": "1:29:29", Total descent time
         "plaintime": "0:57:03", Total plain time
         "climbtime": "3:49:29", Total climb time
         "climbspeed": "12.2", Average climb speed
         "plainspeed": "21.15", Plain speed
         "descentspeed": "33.47" Average descent speed
         "totalhialtidist": "51.293", Total high altitude distance
         "tothiperctotal": "43.96", Percent high altitude distance
         "tothialtmovtime": "3:13:28", Total movement high altitude distance
         "tothialtspeed": "15.91", Speed high altitude
         "tothialtstop": "0:11:42", High altitude stop time
         "tothialttime": "3:25:10", High altitude time
         "tothialttotspeed": "15", Total speed high altitude
         "highaltitudes": [ High altitudes split, [0] for the first, [1] for the second etc.
             { [0]
                 "hialtimeter": "2250", High altitude hight
                 "hialtidist": "5.015", High altitude dist from start
                 "hialtperctotal": "4.3", High altitude percent from total
                 "hialtmovtime": "0:22:57", High altitude movement time
                 "hialtspeed": "13.11", High altitude speed
                 "hialtstop": "0:04:37", High altitude stop time
                 "hialttime": "0:27:34", High altitude total time
                 "hialttotspeed": "10.92" High altitude total speed
             }, 
             { [1]
                 "hialtimeter": "2000", etc.
                 "hialtidist": "8.67", 
                 "hiperctotal": "7.43", 
                 "hialtmovtime": "0:35:25", 
                 "hialtspeed": "14.69", 
                 "hialtstop": "0:02:24", 
                 "hialttime": "0:37:49", 
                 "hialttotspeed": "13.76" 
             }, 
         ], 
         "totalstoptime": "0:17:43", Total stop time
         "stops": [ Stops split, [0] for the first, [1] for the second etc.
             { [0]
                 "stopdistancekm": "30.362", Stop distance from start
                 "stoppedtime": "0:01:15", Stopped time
                 "stopaltitude": "1285", Stop altitude
                 "stopelaptime": "1:35:46", Stop elapsed time
                 "stoplasttime": "1:35:46", Last stop elapsed time
                 "stoplastdist": "30.362" Last stop distance
             }, 
             { [1]
                 "stopdistancekm": "30.642", etc.
                 "stoppedtime": "0:03:06", 
                 "stopaltitude": "1297", 
                 "stopelaptime": "1:38:38", 
                 "stoplasttime": "0:02:52", 
                 "stoplastdist": "0.28" 
             } 
         ] 
     }, 
     "hiking": { Hiking modality*
         "ibp": "344", IBP index
         "acronym": "HKG", Modality acronym (BYC = bicycle, HKG = hiking, RNG = running)
         "ibpfit": "9999", IBP Fit  (9999 Not enought comparison elements)
 etc... 
 *The same for Hiking and Running 


Contacto

info@ibpindex.com

  

¿ Te ha parecido útil el sistema IBP index ?
  • Votos: 0%
  • Votos: 0%
  • Votos: 0%
  • Votos: 0%
Votos Totales:
Primer Voto:
Ultimo Voto:
Top of Page