Example #1
0
 $points = array();
 $cnt = count($geoObject['geo']['points']);
 if (true) {
     $dvd = $cnt > 200 ? 10 : 1;
     while (true) {
         $idx = 0;
         foreach ($geoObject['geo']['points'] as $point) {
             if ($idx == 0 || $idx % $dvd == 0) {
                 array_push($points, array(floatval($point['y']), floatval($point['x'])));
             }
             $idx++;
         }
         if (count($points) > 0) {
             array_push($points, $points[0]);
         }
         $encodedPoints = dpEncode($points);
         if (strlen($encodedPoints[0]) < 1900) {
             break;
         } else {
             $dvd = $dvd * 2;
         }
     }
     if (@$_REQUEST['debug']) {
         print "points=" . $cnt . '   ' . $dvd . '   ' . strlen($encodedPoints[0]) . '<br>';
     }
     $poly_all = $poly_all . "&path=" . $style_poly . "|enc:" . $encodedPoints[0];
 } else {
     foreach ($geoObject['geo']['points'] as $point) {
         if ($poly == "") {
             $firstpoint = $point['y'] . "," . $point['x'];
         }
            if (!preg_match("/LINESTRING\\((.+)\\)/i", $val[2], $matches)) {
                continue;
            }
            if (!preg_match_all("/\\S+\\s+\\S+(?:,|\$)/", $matches[1], $matches)) {
                continue;
            }
            $matches = $matches[0];
            $points = array();
            for ($j = 0; $j < count($matches) - 1; ++$j) {
                preg_match("/(\\S+)\\s+(\\S+)(?:,|\$)/", $matches[$j], $match_matches);
                array_push($points, array(floatval($match_matches[2]), floatval($match_matches[1])));
            }
            if (count($points) <= 1) {
                continue;
            }
            $encoding = dpEncode($points);
            array_push($geoObjects, array("bibID" => $val[0], "type" => "path", "geo" => array("points" => $encoding[0], "levels" => $encoding[1], "bounds" => $bbox)));
    }
    $geoBibIDs[$val[0]] = $val[0];
}
// OLD WAY TO STORE GEO DATA - directly in dtl_value as dettypes: 210(long) and 211(lat)
$res = mysql_query("select LAT.dtl_RecID, LNG.dtl_Value, LAT.dtl_Value from recDetails LAT, recDetails LNG where LAT.dtl_DetailTypeID=211 and LNG.dtl_DetailTypeID=210 and LAT.dtl_RecID=LNG.dtl_RecID and LNG.dtl_RecID in (" . join(",", $bibIDs) . ")");
while ($val = mysql_fetch_row($res)) {
    array_push($geoObjects, array("bibID" => $val[0], "type" => "point", "geo" => array("x" => floatval($val[1]), "y" => floatval($val[2]))));
    $geoBibIDs[$val[0]] = $val[0];
}
// Find time extents -- must have at least a start time (end time is optional)
/*
$timeObjects = array();
$res = mysql_query("select START.dtl_RecID, START.dtl_Value, END.dtl_Value from recDetails START left join recDetails END on START.dtl_RecID=END.dtl_RecID and END.dtl_DetailTypeID=178 where START.dtl_DetailTypeID=177 and START.dtl_Value and START.dtl_RecID in (" . join(",", $bibIDs) . ")");
while ($val = mysql_fetch_row($res)) {