<?php
$netFanyiArr = explode("\n",$netFanyiStr);
$action = trim($_GET['action']);
$cityName = trim($_GET['city']);
if(empty($action)){
    exit('action 不能为空');
}
if($action == "get"){
//view-source:http://127.0.0.1:81/ypmvc/qg/pzMap/qg/fanyi.php?action=get
    $filename = '../maps/SurvivalL0/overlays.json';
    $overlaysJsonStr = file_get_contents($filename);
    $overlays = json_decode($overlaysJsonStr,true);
    foreach ($overlays['areas'] as $i=>$city){
        foreach ($city['pois'] as $j=>$pois){
            $id = $pois['id'];
            $pois['comment'] = str_replace("\n","<br>",$pois['comment']);
            echo $city['id'].'@'.$id.'@'.$pois['name'].'@'.$pois['comment']."\n";
        }
    }
}else if($action == "set"){
//view-source:http://127.0.0.1:81/ypmvc/qg/pzMap/qg/fanyi.php?action=set 
    $fanyiTxtArr = file('../maps/SurvivalL0/fanyi.txt');
    $pois = [];
    foreach ($fanyiTxtArr as $line){
        list($area_id,$id,$name,$comment) = explode('@',$line);
        $pois[$id] = [
            'id'=>$id,
            'name'=>trim($name),
            'comment'=>trim($comment),
            'qg'=>0,
        ];
    }
    $jsonStr = json_encode($pois,JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
    file_put_contents('../maps/SurvivalL0/fanyi.json',$jsonStr);
    echo "创建 fanyi.json 完成";
}