/** * Creates a GML object from a GeoJSON (http://www.geojson.org) String * * @return Gml * @param $geoJson String */ public function createFromGeoJson($geoJson, $wfsConf = null) { if (is_a($wfsConf, "WfsConfiguration")) { $wfsFactory = new UniversalWfsFactory(); $myWfsFactory = $wfsFactory->createFromDb($wfsConf->wfsId); if (is_a($myWfsFactory, "Wfs_1_1")) { $gml3Factory = new Gml_3_Factory(); return $gml3Factory->createFromGeoJson($geoJson); } if (is_a($myWfsFactory, "Wfs_1_0")) { $gml2Factory = new Gml_2_Factory(); return $gml2Factory->createFromGeoJson($geoJson); } throw new Exception("UniversalGmlFactory: Unknown WFS version"); } else { $gml2Factory = new Gml_2_Factory(); return $gml2Factory->createFromGeoJson($geoJson); } }
function deleteWfs($obj) { $id = $obj->wfs; $wfsFactory = new UniversalWfsFactory(); $myWfs = $wfsFactory->createFromDb($id); if (is_null($myWfs) || !$myWfs->delete()) { $obj->success = false; } else { $obj->success = true; } return true; }
$nodeArray = addSubTree($rows, 0, 1); $resultObj = array("nestedSets" => $nodeArray); $ajaxResponse->setResult($resultObj); $ajaxResponse->setSuccess(true); break; case "save": $data = $ajaxResponse->getParameter("data"); try { $wfsId = intval($data->wfs->wfs_id); } catch (Exception $e) { $ajaxResponse->setSuccess(false); $ajaxResponse->setMessage(_mb("Invalid WFS ID.")); $ajaxResponse->send(); } getWfs($wfsId); $wfsFactory = new UniversalWfsFactory(); $wfs = $wfsFactory->createFromDb($wfsId, false); if (is_null($wfs)) { $ajaxResponse->setSuccess(false); $ajaxResponse->setMessage(_mb("Invalid WFS ID.")); $ajaxResponse->send(); } $columns = array("summary", "title", "fees", "accessconstraints", "individualName", "positionName", "voice", "facsimile", "providerName", "deliveryPoint", "city", "administrativeArea", "postalCode", "country", "electronicMailAddress", "wfs_termsofuse", "timestamp", "timestamp_create", "network_access", "fkey_mb_group_id", "uuid"); foreach ($columns as $c) { $value = $data->wfs->{$c}; if (!is_null($value)) { $wfs->{$c} = $value; } } try { $featuretypeId = intval($data->featuretype->featuretype_id);
/** * Creates GML objects from GML documents. * * @return Gml * @param $xml String */ public function createFromXml($xml, $wfsConf, $gml) { try { $xml = $this->removeWhiteSpace($xml); $gmlDoc = new SimpleXMLElement($xml); // we need to find the name and namespaces of the featuretype // used in this WFS configuration $wfsFactory = new UniversalWfsFactory(); $myWfs = $wfsFactory->createFromDb($wfsConf->wfsId); if (is_null($myWfs)) { new mb_exception("class_gml_factory.php: createFromXml: WFS not found! ID: " . $wfsConf->wfsId); return null; } $featureType = $myWfs->findFeatureTypeById($wfsConf->featureTypeId); // register namespace of feature type $pos = strpos($featureType->name, ":"); if ($pos !== false) { $ns = substr($featureType->name, 0, $pos); $url = $featureType->getNamespace($ns); $gmlDoc->registerXPathNamespace($ns, $url); } $gmlDoc->registerXPathNamespace('xls', 'http://www.opengis.net/xls'); $gmlDoc->registerXPathNamespace('wfs', 'http://www.opengis.net/wfs'); $gmlDoc->registerXPathNamespace('gml', 'http://www.opengis.net/gml'); // build feature collection $gml->featureCollection = new FeatureCollection(); // segments of the featureCollection // // for *non* Mapserver WFS $gmlFeatureMembers = $gmlDoc->xpath("//gml:featureMember"); if (count($gmlFeatureMembers) > 0) { foreach ($gmlFeatureMembers as $gmlFeatureMember) { $gmlfeatureMember_dom = dom_import_simplexml($gmlFeatureMember); $feature = new Feature(); $this->parseFeature($gmlfeatureMember_dom->firstChild, $feature, $wfsConf); if (isset($feature->geometry)) { $gml->featureCollection->addFeature($feature); } } } else { // segments of the featureCollection $gmlFeatureMembers = $gmlDoc->xpath("//" . $featureType->name); if (count($gmlFeatureMembers) > 0) { foreach ($gmlFeatureMembers as $gmlFeatureMember) { $gmlfeatureMember_dom = dom_import_simplexml($gmlFeatureMember); $feature = new Feature(); $this->parseFeature($gmlfeatureMember_dom, $feature, $wfsConf); if (isset($feature->geometry)) { $gml->featureCollection->addFeature($feature); } } } } return $gml; } catch (Exception $e) { $e = new mb_exception($e); return null; } }
$backlink = $_REQUEST["backlink"]; $frame = $_REQUEST["frame"]; $filter = $_REQUEST["filter"]; $url = $_REQUEST["url"]; $typename = $_REQUEST["typename"]; $destSrs = $_REQUEST["destSrs"]; $wfsConf = WfsConfiguration::createFromDb($wfs_conf_id); if (is_null($wfsConf)) { sendErrorMessage("Invalid WFS conf: " . $wfs_conf_id); } // append authorisation condition to filter $filter = checkAccessConstraint($filter, $wfs_conf_id); $admin = new administration(); $filter = administration::convertIncomingString($filter); $wfsId = $wfsConf->wfsId; $myWfsFactory = new UniversalWfsFactory(); $myWfs = $myWfsFactory->createFromDb($wfsId); $data = $myWfs->getFeature($typename, $filter, $destSrs); if ($data === null) { die('{}'); } if (defined("WFS_RESPONSE_SIZE_LIMIT") && WFS_RESPONSE_SIZE_LIMIT < strlen($data)) { die("Too many results, please restrict your search."); } // $geomColumn = WfsConf::getGeomColumnNameByConfId($wfs_conf_id); $gmlFactory = new UniversalGmlFactory(); $myGml = $gmlFactory->createFromXml($data, $wfsConf); if (!is_null($myGml)) { $geoJson = $myGml->toGeoJSON(); } else { $geoJson = "{}";
# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. require_once dirname(__FILE__) . "/../php/mb_validateSession.php"; require_once dirname(__FILE__) . "/mb_validateInput.php"; require_once dirname(__FILE__) . "/../classes/class_universal_wfs_factory.php"; require_once dirname(__FILE__) . "/../classes/class_gui.php"; echo "file: " . $_REQUEST["xml_file"]; echo "<br>-------------------------------<br>"; $guiList = mb_validateInput($_REQUEST["guiList"]); $url = mb_validateInput($_REQUEST["xml_file"]); $myWfsFactory = new UniversalWfsFactory(); $myWfs = $myWfsFactory->createFromUrl($url); if (is_null($myWfs)) { echo "WFS could not be uploaded."; die; } $myWfs->insertOrUpdate(); // link WFS to GUIs in $guiList $guiArray = explode(",", $guiList); foreach ($guiArray as $appName) { $currentApp = new gui($appName); $currentApp->addWfs($myWfs); } echo $myWfs;