예제 #1
0
파일: LoadMap.php 프로젝트: kanbang/Colt
function GetLayerTypesFromResourceContent($layer, $xmldoc = NULL)
{
    $aLayerTypes = array();
    global $resourceService;
    try {
        $dataSourceId = new MgResourceIdentifier($layer->GetFeatureSourceId());
        if ($dataSourceId->GetResourceType() == MgResourceType::DrawingSource) {
            array_push($aLayerTypes, '5');
        } else {
            if ($xmldoc == NULL) {
                $resID = $layer->GetLayerDefinition();
                $layerContent = $resourceService->GetResourceContent($resID);
                $xmldoc = DOMDocument::loadXML(ByteReaderToString($layerContent));
            }
            $gridlayers = $xmldoc->getElementsByTagName('GridLayerDefinition');
            if ($gridlayers->length > 0) {
                array_push($aLayerTypes, '4');
            }
            // raster
            $scaleRanges = $xmldoc->getElementsByTagName('VectorScaleRange');
            $typeStyles = array("PointTypeStyle", "LineTypeStyle", "AreaTypeStyle", "CompositeTypeStyle");
            for ($sc = 0; $sc < $scaleRanges->length; $sc++) {
                $scaleRange = $scaleRanges->item($sc);
                for ($ts = 0, $count = count($typeStyles); $ts < $count; $ts++) {
                    $typeStyle = $scaleRange->getElementsByTagName($typeStyles[$ts]);
                    if ($typeStyle->length > 0) {
                        array_push($aLayerTypes, $ts);
                    }
                }
            }
        }
    } catch (MgException $e) {
        echo "ERROR: " . $e->GetExceptionMessage() . "\n";
        echo $e->GetDetails() . "\n";
        echo $e->GetStackTrace() . "\n";
    }
    $aLayerTypes = array_unique($aLayerTypes);
    return $aLayerTypes;
}
예제 #2
0
파일: Utilities.php 프로젝트: kanbang/Colt
function GetLayerTypes($featureService, $layer)
{
    $aLayerTypes = array();
    try {
        $dataSourceId = new MgResourceIdentifier($layer->GetFeatureSourceId());
        if ($dataSourceId->GetResourceType() != MgResourceType::DrawingSource) {
            //get class definition from the featureSource
            $classDefinition = GetFeatureClassDefinition($featureService, $layer, $dataSourceId);
            //MgPropertyDefinition classProps
            $classProps = $classDefinition->GetProperties();
            $aLayerTypes = array();
            for ($i = 0; $i < $classProps->GetCount(); $i++) {
                $prop = $classProps->GetItem($i);
                if ($prop->GetPropertyType() == MgFeaturePropertyType::GeometricProperty) {
                    $featureClass = $prop->GetGeometryTypes();
                    if ($featureClass & MgFeatureGeometricType::Surface) {
                        array_push($aLayerTypes, '2');
                    }
                    if ($featureClass & MgFeatureGeometricType::Curve) {
                        array_push($aLayerTypes, '1');
                    }
                    if ($featureClass & MgFeatureGeometricType::Solid) {
                        array_push($aLayerTypes, '3');
                        //could use surface here for editing purposes?
                    }
                    if ($featureClass & MgFeatureGeometricType::Point) {
                        array_push($aLayerTypes, '0');
                    }
                    break;
                } else {
                    if ($prop->GetPropertyType() == MgFeaturePropertyType::RasterProperty) {
                        array_push($aLayerTypes, '4');
                    }
                }
            }
        } else {
            array_push($aLayerTypes, '5');
        }
    } catch (MgException $e) {
    }
    return $aLayerTypes;
}
예제 #3
0
 public function CreateMap($resId)
 {
     $mdfIdStr = $this->app->request->params("mapdefinition");
     if ($mdfIdStr == null) {
         $this->BadRequest($this->app->localizer->getText("E_MISSING_REQUIRED_PARAMETER", "mapdefinition"), $this->GetMimeTypeForFormat($format));
     } else {
         $mdfId = new MgResourceIdentifier($mdfIdStr);
         if ($mdfId->GetResourceType() != MgResourceType::MapDefinition) {
             $this->BadRequest($this->app->localizer->getText("E_INVALID_MAP_DEFINITION_PARAMETER", "mapdefinition"), $this->GetMimeTypeForFormat($format));
         } else {
             //$this->EnsureAuthenticationForSite();
             $userInfo = new MgUserInformation($resId->GetRepositoryName());
             $siteConn = new MgSiteConnection();
             $siteConn->Open($userInfo);
             $resSvc = $siteConn->CreateService(MgServiceType::ResourceService);
             $map = new MgMap();
             $map->Create($resSvc, $mdfId, $resId->GetName());
             $sel = new MgSelection($map);
             $sel->Save($resSvc, $resId->GetName());
             $map->Save($resSvc, $resId);
             $this->app->response->setStatus(201);
             $this->app->response->setBody(MgUtils::GetNamedRoute($this->app, "/session", "session_resource_id", array("sessionId" => $resId->GetRepositoryName(), "resName" => $resId->GetName() . "." . $resId->GetResourceType())));
         }
     }
 }