完善地图可视化编辑

This commit is contained in:
Li Jianxuan 2015-02-11 09:05:38 +00:00
parent c6f4df21c1
commit bf150590b0
3 changed files with 51 additions and 6 deletions

View File

@ -4170,7 +4170,7 @@ class Admin_DataController extends Zend_Controller_Action
$data = [ $data = [
'uuid' => $uuid, 'uuid' => $uuid,
'status' => $this->_getParam('status'), 'status' => $this->_getParam('status'),
'layers' => $this->_getParam('status'), 'layers' => $this->_getParam('layers'),
'zoom_min' => $this->_getParam('zoom_min'), 'zoom_min' => $this->_getParam('zoom_min'),
'zoom_max' => $this->_getParam('zoom_max'), 'zoom_max' => $this->_getParam('zoom_max'),
'zoom_default' => $this->_getParam('zoom_default'), 'zoom_default' => $this->_getParam('zoom_default'),

View File

@ -116,7 +116,6 @@
</div> </div>
<?php if(!empty($this->info['layers'])) { ?> <?php if(!empty($this->info['layers'])) { ?>
<?php var_dump($this->info['layers']) ?>
<?php $vars = array() ?> <?php $vars = array() ?>
<?php $encoder = new \Westdc\Visual\VariableEncoder; ?> <?php $encoder = new \Westdc\Visual\VariableEncoder; ?>
<?php $vars = $encoder->decode($this->info['layers']);?> <?php $vars = $encoder->decode($this->info['layers']);?>
@ -128,7 +127,7 @@
<input type="text" placeholder="类型" name="layers[<?= $index ?>][type]" class="input-xlarge" value="<?= $value['type'] ?>"> <input type="text" placeholder="类型" name="layers[<?= $index ?>][type]" class="input-xlarge" value="<?= $value['type'] ?>">
</div> </div>
<div class="controls" style="padding-top:10px;"> <div class="controls" style="padding-top:10px;">
<input type="text" placeholder="url" name="layers[<?= $index ?>][sql]" class="input-block-level" value="<?= $value['url'] ?>"> <input type="text" placeholder="url" name="layers[<?= $index ?>][url]" class="input-block-level" value="<?= $value['url'] ?>">
</div> </div>
<div class="controls" style="padding-top:10px;"> <div class="controls" style="padding-top:10px;">
<input type="text" placeholder="最大经度" name="layers[<?= $index ?>][extent][lon_max]" class="input-mini" value="<?= $value['extent']['lon_max'] ?>"> <input type="text" placeholder="最大经度" name="layers[<?= $index ?>][extent][lon_max]" class="input-mini" value="<?= $value['extent']['lon_max'] ?>">

View File

@ -32,6 +32,10 @@ class Map {
} }
} }
/**
* 查询所有地图可视化
* @return mixed
*/
public function fetchAll() public function fetchAll()
{ {
$sql = "SELECT * FROM {$this->metadataTable} md $sql = "SELECT * FROM {$this->metadataTable} md
@ -43,6 +47,11 @@ class Map {
return $rs->fetchAll(\PDO::FETCH_ASSOC); return $rs->fetchAll(\PDO::FETCH_ASSOC);
} }
/**
* 获得某一条可视化信息
* @param $uuid
* @return mixed
*/
public function fetch($uuid) public function fetch($uuid)
{ {
$sql = "SELECT * FROM {$this->mainTable} WHERE uuid='$uuid'"; $sql = "SELECT * FROM {$this->mainTable} WHERE uuid='$uuid'";
@ -51,39 +60,76 @@ class Map {
return $rs->fetch(\PDO::FETCH_ASSOC); return $rs->fetch(\PDO::FETCH_ASSOC);
} }
/**
* 删除一条
* @param $id
* @return mixed
*/
public function delete($id) public function delete($id)
{ {
$sql = "DELETE FROM {$this->mainTable} WHERE id=$id"; $sql = "DELETE FROM {$this->mainTable} WHERE id=$id";
return $this->db->exec($sql); return $this->db->exec($sql);
} }
/**
* 添加一条
* @param $data
* @return bool
*/
public function add($data){ public function add($data){
$dbh = new dbh(); $dbh = new dbh();
if($this->checkExists($data['uuid']) === true) if($this->checkExists($data['uuid']) === false)
return $dbh->insert($this->mainTable,$data); return $dbh->insert($this->mainTable,$data);
return $dbh->update($this->mainTable,$data," uuid={$data['uuid']} "); return $dbh->update($this->mainTable,$data," uuid='{$data['uuid']}' ");
} }
/**
* 处理表单中接收的数据
* @param $data
* @return mixed
*/
public function processParam($data){ public function processParam($data){
if(is_array($data['layers']) && count($data['layers'])){ if(is_array($data['layers']) && count($data['layers'])){
foreach($data['layers'] as $index=>$value){ foreach($data['layers'] as $index=>$value){
if(!is_array($value) || count($value) < 1) { if(!is_array($value) || count($value) < 1) {
unset($data['layers']['index']); unset($data['layers']['index']);
continue; continue;
} }
if(empty(array_filter($value['extent'])))
unset($value['extent']);
if(empty(array_filter($value))){
unset($data['layers'][$index]);
continue;
}
} }
$data['layers'] = json_encode($data['layers'],JSON_NUMERIC_CHECK); $data['layers'] = json_encode($data['layers'],JSON_UNESCAPED_UNICODE);
}else{
$data['layers'] = json_encode([]);
} }
$data['zoom_min'] = (int)$data['zoom_min'] + 0;
$data['zoom_max'] = (int)$data['zoom_max'] + 0;
$data['zoom_default'] = (int)$data['zoom_default'] + 0;
$data['center_lon'] = (float)$data['center_lon'];
$data['center_lon'] = (float)$data['center_lon'];
return $data; return $data;
} }
/**
* 检查某条信息是否存在
* @param $uuid
* @return bool
*/
public function checkExists($uuid){ public function checkExists($uuid){
$row = $this->fetch($uuid); $row = $this->fetch($uuid);