jQuery('#TreeTableMap').TableAjaxMap({
wpsUrl: 'http://biuro.biall-net.pl/wps',
wfsUrl: 'http://biuro.biall-net.pl/wps'
});
*
*/
class TableAjaxMap {
private $_acl;
private $_zasobID;
private $_width;
private $_height;
public function __construct($tblAcl, $width = 512, $height = 256) {
$this->_acl = $tblAcl;
$this->_zasobID = $tblAcl->getID();
$this->_width = $width;
$this->_height = $height;
}
public function printCSS() {
//
//
?>
_zasobID);
$testFirstLayer = (count($layers))? $layers[0] : array();
?>
sendAjaxProxy($_REQUEST);
break;
}
}
}
catch (HttpException $e) {
Http::sendHeaderByCode($e->getCode());
echo $e->getMessage();
}
catch (Exception $e) {
echo $e->getMessage();
}
exit;
}
public function sendAjaxProxy($args) {
$wpsServer = null;
$url = V::get('url', '', $args);
// 1. http%3A%2F%2Fbiuro.biall-net.pl%2Fwps%3FSERVICE%3DWPS%26REQUEST%3DGetCapabilities
// 2. http%3A%2F%2Fbiuro.biall-net.pl%2Fwps%3FSERVICE%3DWPS%26REQUEST%3DDescribeProcess%26VERSION%3D1.0.0%26IDENTIFIER%3Dpozdrawiam
header('Content-Type: application/xml; charset=utf-8');
$urlParts = parse_url($url);
$urlPath = V::get('path', '', $urlParts);
$urlQuery = array();
$urlQueryTmp = V::get('query', '', $urlParts);
$urlQueryTmp = explode('&', $urlQueryTmp);
foreach ($urlQueryTmp as $vQuery) {
$parts = explode('=', $vQuery, 2);
$urlQuery[$parts[0]] = (count($parts) > 1)? $parts[1] : '';
}
$urlPath = explode('/', trim($urlPath, "/ \n\t\r\0\x0B"));
if (count($urlPath) > 2) {// /wps/21176/BUILDINGS_PODKLAD_DXF_SHP
$tableId = $urlPath[1];
$layers = TableAjaxMap::getAdditionalLayers($this->_zasobID);
$hasLayer = false;
foreach ($layers as $layer) {
if ($layer->TABLE_ID == $tableId) {
$hasLayer = true;
break;
}
}
if (!$hasLayer) {
throw new HttpException("Layer not found", 404);
}
$userAcl = User::getAcl();
$userAcl->fetchGroups();
if (!$userAcl->hasTableAcl($tableId)) {
throw new HttpException("Forbidden", 403);
}
$tblAcl = $userAcl->getTableAcl($tableId);
if (!$tblAcl) {
throw new HttpException("Forbidden", 403);
}
$tblAcl->init();
$wpsServer = new TableAjaxMapWpsServer($tblAcl);
}
if (!$wpsServer) {
$wpsServer = new TableAjaxMapWpsServer($this->_acl);
}
if ('WPS' == V::get('SERVICE', '', $urlQuery)) {
$req = V::get('REQUEST', '', $urlQuery);
$methodName = "{$req}Action";
if (method_exists($wpsServer, $methodName)) {
$wpsServer->$methodName($urlQuery);
}
}
else {
$wpsServer->parseXMLRequest();
}
exit;
}
/**
* usage: TableAjaxMap::getAdditionalLayers($idTable);
*/
public static function getAdditionalLayers($idTable) {
static $_cache;
if (!is_array($_cache)) $_cache = array();
if (!array_key_exists($idTable, $_cache)) {
$layers = array();
$sql = "
select layer.`ID`
, layer.`DESC`
, layer.`DESC_PL`
, layer.`OPIS`
, layer.`ALIAS_ID`
, tbl.`ID` as TABLE_ID
, tbl.`DESC` as TABLE_DESC
, tbl.`DESC_PL` as TABLE_DESC_PL
from `CRM_LISTA_ZASOBOW` as layers
join `CRM_LISTA_ZASOBOW` as layer on(
layer.`PARENT_ID`=layers.`ID`
and layer.`A_STATUS` in('WAITING', 'NORMAL')
and layer.`ALIAS_ID`>0
and layer.`DESC`='MAP_ADDITIONAL_LAYER'
)
join `CRM_LISTA_ZASOBOW` as tbl on(tbl.`ID`=layer.`ALIAS_ID` and tbl.`A_STATUS` in('WAITING', 'NORMAL'))
where layers.`PARENT_ID`='{$idTable}'
and layers.`A_STATUS` in('WAITING', 'NORMAL')
and layers.`DESC`='MAP_ADDITIONAL_LAYERS'
order by layer.`SORT_PRIO`
";
$layers = array_map(function ($row) {
return (object)$row;
}, DB::getPDO()->fetchAll($sql));
$_cache[$idTable] = $layers;
}
return $_cache[$idTable];
}
}
class TableAjaxMapWfsAction {
private $_acl;
private $_zasobID;
public function __construct($acl) {
$this->_acl = $acl;
$this->_zasobID = $acl->getID();
}
/**
* example: MULTIPOLYGON(((2072016.74395199 7234076.79293037,2072016.74395199 7234115.01144451,2072131.3994944 7234115.01144451,2072131.3994944 7234076.79293037,2072016.74395199 7234076.79293037)))
*/
public function generateGmlFromWKT($wkt) {
$gml = '';
$wktParts = explode('(', $wkt, 2);
ob_start();
switch ($wktParts[0]) {
// case 'MULTIPOLYGON':
case 'POLYGON': {
$points = trim($wktParts[1], '() ');
$points = str_replace(',', "\n", $points);
?>
-180 -90
180 90
45.67 88.56
// 45.67, 88.56
?>
-180 -90
180 90
-180 -90
180 90
_acl->buildQuery($params)->getItems();
$buildingsGml = array();
foreach ($items as $item) {
if (!empty( $item['the_geom'] )) {
$buildingsGml[ $item['@primaryKey'] ] = $this->generateGmlFromWKT( $item['the_geom'] );
}
}
/**
*
*
*
* goes to js: @see priv.addWKTInput _layer.selectedFeatures[0]
*
* attributes: Object
recordId: "1130"
tblId: "16"
*/
echo '';
?>
-180 -90
180 90
$vGml) : ?>
_zasobID; ?>
title = 'Przypisz';
$this->description = 'Przypisuje położenie do wybranego rekordu w tabeli.';
$this->dataInputs['geom'] = new stdClass();
$this->dataInputs['geom']->title = 'geom';
$this->dataInputs['geom']->description = 'Input geometry';
$this->dataInputs['geom']->type = 'geom';// CoomplexData
$this->dataInputs['idTable'] = new stdClass();
$this->dataInputs['idTable']->title = 'geom';
$this->dataInputs['idTable']->description = 'Table ID';
$this->dataInputs['idTable']->type = 'integer';// LiteralData: xs:integer
$this->dataInputs['idRecord'] = new stdClass();
$this->dataInputs['idRecord']->title = 'idRecord';
$this->dataInputs['idRecord']->description = 'Record ID';
$this->dataInputs['idRecord']->type = 'integer';// LiteralData: xs:integer
}
}
class TableAjaxMapWpsServer {
private $_fun;// config for identifiers
private $_wfsAction;
private $_zasobID;
private $_acl;
public function __construct($acl) {
$this->_fun['przypiszDoRekordu'] = new WpsActionPrzypiszDoRekordu();
$this->_acl = $acl;
$this->_zasobID = $acl->getID();
$this->_wfsAction = new TableAjaxMapWfsAction($this->_acl);
}
public function parseXMLRequest() {
$data = array();
$reqContent = Request::getRequestBody();
$xml = new SimpleXMLElement($reqContent);
if ('GetFeature' == $xml->getName()) {
// TODO: parse xml and set query params
/*
the_geom
17.226562502593 53.887024366231
20.039062502593 54.847089981191
*/
$corners = null;
$xmlTag = $xml->children("wfs", TRUE)->Query;
if (!empty($xmlTag)) {
$xmlTag = $xmlTag->children("ogc", TRUE)->Filter;
if (!empty($xmlTag)) {
$xmlTag = $xmlTag->BBOX;
if (!empty($xmlTag)) {
$xmlTag = $xmlTag->children("gml", TRUE)->Envelope;
if (!empty($xmlTag)) {
$corners = (object)array('lowerCorner' => (string)$xmlTag->lowerCorner, 'upperCorner' => (string)$xmlTag->upperCorner);
}
}
}
}
if ($corners) {
$lowerCorner = (string) $corners->lowerCorner;
$upperCorner = (string) $corners->upperCorner;
$lowerCorner = explode(" ", trim($lowerCorner));
$upperCorner = explode(" ", trim($upperCorner));
if (count($lowerCorner) == 2 && count($upperCorner) == 2) {
$points = array();
$points[] = $upperCorner[1];// top
$points[] = $upperCorner[0];// right
$points[] = $lowerCorner[1];// bottom
$points[] = $lowerCorner[0];// left
$isAllNumeric = true;
foreach ($points as $point) {
if (!is_numeric($point)) $isAllNumeric = false;
}
if ($isAllNumeric) {
$data['BBOX'] = $points;
}
}
} else {
// inna struktura xml'a
}
$this->_wfsAction->execute($data);
}
else if (isset($xml->children('ows', TRUE)->Identifier)) {
$identifier = (string)$xml->children('ows', TRUE)->Identifier;
if (array_key_exists($identifier, $this->_fun)) {
foreach ($xml->children('wps', TRUE)->DataInputs->children('wps', TRUE) as $input) {
$inputIdentifier = (string)$input->children('ows', TRUE)->Identifier;
if (array_key_exists($inputIdentifier, $this->_fun[$identifier]->dataInputs)) {
$inputType = (string)$this->_fun[$identifier]->dataInputs[$inputIdentifier]->type;
switch ($inputType) {
case 'integer':
$data[$inputIdentifier] = (string)$input->children('wps', TRUE)->Data->LiteralData;
break;
case 'geom':
$data[$inputIdentifier] = (string)$input->children('wps', TRUE)->Data->ComplexData;
break;
default:
}
} else {
// brak zdefiniowanego inputa
}
}
$this->_fun['przypiszDoRekordu']->execute($data);
} else {
echo "TODO: brak zdefiniowanej funkcji '{$identifier}'";
var_dump($identifier);
}
}
else {
echo "TODO: '" . $xml->getName() . "' ...";
}
}
public function getCapabilitiesAction() {
echo '';
?>
Prototype GeoServer WPS
wps
geoserver
WPS
1.0.0
NONE
NONE
GeoServer
_fun as $kFun => $vFun) : ?>
title; ?>
description; ?>
en-US
en-US
';
if (array_key_exists($args['IDENTIFIER'], $this->_fun)) {
$identifier = $this->_fun[$args['IDENTIFIER']];
?>
title; ?>
description; ?>
dataInputs as $kInput => $vInput) : ?>
title; ?>
description; ?>
type == 'geom') : ?>
text/xml; subtype=gml/3.1.1
text/xml; subtype=gml/3.1.1
text/xml; subtype=gml/2.1.2
application/wkt
application/gml-3.1.1
application/gml-2.1.2
type == 'integer') : ?>
xs:integer