QuartzMap/admin/snippets/data_gs.php

40 lines
960 B
PHP
Raw Normal View History

2024-03-16 23:03:30 +00:00
var VARNAME =
<?php
const MAP_ID = MAP_ID_VALUE;
include('../../admin/snippets/index_prefix.php');
const CACHE_PERIOD = CACHE_PERIOD_SECONDS;
const GS_URL = 'FULL_URL';
if(CACHE_PERIOD == 0){
readfile(GS_URL);
}else {
$js_file = CACHE_DIR.'/MAP_ID_VALUE/VARNAME_data.js';
if(!is_file($js_file) || (time() - filemtime($js_file)) > CACHE_PERIOD){
if(!is_dir(CACHE_DIR.'/MAP_ID_VALUE')){
mkdir(CACHE_DIR.'/MAP_ID_VALUE');
}
$fin = fopen(GS_URL, 'r');
$fout = fopen($js_file, 'w');
while(($contents = fread($fin, 4096))){
fwrite($fout, $contents);
}
fclose($fin);
fclose($fout);
}
readfile($js_file);
}
?>
;
{
let qc_id = 0;
VARNAME.features.forEach(function (feat) { feat.properties["qc_id"] = qc_id; qc_id = qc_id + 1;});
if(VARNAME.features[0].properties["gid"] === undefined){
let gid = 0;
VARNAME.features.forEach(function (feat) { feat.properties["gid"] = gid; gid = gid + 1;});
}
}