void DescribeCsvResponse::WriteDocument(XDocument* pxDoc)
	{
		const char* setName = m_pDataset->GetName();
		char str[AUGE_NAME_MAX];

		XElement  *pxNode = NULL;
		XElement  *pxRoot = NULL;
		pxRoot = pxDoc->CreateRootNode("schema", NULL, NULL);
		pxRoot->SetNamespaceDeclaration("http://www.opengis.net/wfs",NULL);
		pxRoot->SetNamespaceDeclaration("http://www.opengis.net/wfs","wfs");
		pxRoot->SetNamespaceDeclaration("http://www.opengis.net/ows","ows");
		pxRoot->SetNamespaceDeclaration("http://www.opengis.net/gml","gml");
		pxRoot->SetNamespaceDeclaration("http://www.w3.org/1999/xlink","xlink");
		pxRoot->SetNamespaceDeclaration("http://www.w3.org/2001/XMLSchema-instance","xsi");
		pxRoot->SetNamespaceDeclaration("http://www.w3.org/2001/XMLSchema","xsd");		
		pxRoot->SetAttribute("version", "1.1.0", NULL);

		// schema-->import
		XElement* pxImport = pxRoot->AddChild("import", "xsd");
		pxImport->SetAttribute("namespace","http://www.opengis.net/gml", NULL);
		// schema-->complexType
		g_sprintf(str,"%sType", setName);
		XElement* pxComplexType = pxRoot->AddChild("complexType", "xsd");
		pxComplexType->SetAttribute("name", str, NULL, true);
		// schema-->complexType-->complexContent
		XElement* pxComplexContent = pxComplexType->AddChild("complexContent","xsd");
		// schema-->complexType-->complexContent-->extentsion
		XElement* pxExtentsion = pxComplexContent->AddChild("extentsion", "xsd");
		pxExtentsion->SetAttribute("base","gml:AbstractFeatureType", NULL);
		// schema-->complexType-->complexContent-->extentsion-->sequence
		XElement* pxSequence = pxExtentsion->AddChild("sequence", "xsd");

		GField	*pField  = NULL;
		GFields	*pFields = m_pDataset->GetFields();
		g_uint count = pFields->Count();
		augeFieldType ftype = augeFieldTypeNone;

		// schema-->complexType-->complexContent-->extentsion-->sequence-->element
		XElement* pxElement = NULL;
		for(g_uint i=0; i<count; i++)
		{
			pField = pFields->GetField(i);
			pxElement = pxSequence->AddChild("element", "xsd");
			const char* fname = pField->GetName();
			const char* utf8_name = auge_encoding_convert("GBK","UTF-8",fname,strlen(fname));
			pxElement->SetAttribute("name",utf8_name, NULL);
			pxElement->SetAttribute("nillable",pField->IsNullable()?"true":"false", NULL);
			pxElement->SetAttribute("minOccurs","0", NULL);
			pxElement->SetAttribute("maxOccurs","1", NULL);
			pxElement->SetAttribute("type","xsd:string", NULL);
		}

		// schema-->element
		pxElement = pxRoot->AddChild("element", "xsd");
		g_sprintf(str, "%sType", setName);
		pxElement->SetAttribute("type",str, NULL, true);
		pxElement->SetAttribute("name",setName, NULL, true);
		pxElement->SetAttribute("substitutionGroup","gml:_Feature", NULL);
	}
Beispiel #2
0
	void GetSymbolResponse::WriteSymbol(XDocument* pxDoc)
	{
		XElement  *pxNode = NULL;
		XElement  *pxRoot = NULL;
		char str[AUGE_MSG_MAX];

		pxRoot = pxDoc->CreateRootNode("Symbols", NULL, NULL);
		//pxRoot->SetNamespaceDeclaration("http://www.opengis.net/wms",NULL);
		pxRoot->SetNamespaceDeclaration("http://www.w3.org/1999/xlink","xlink");
		//pxRoot->SetNamespaceDeclaration("http://www.w3.org/2001/XMLSchema-instance","xsi");
		//pxRoot->SetAttribute("version", "1.0.0", NULL);

		Symbol* pSymbol = m_pSymbol;
		AddSymbolNode(pxRoot, pSymbol);
	}
Beispiel #3
0
	void GetSymbolResponse::WriteSymbols(XDocument* pxDoc)
	{
		GLogger* pLogger = augeGetLoggerInstance();

		XElement	*pxNode = NULL;
		XElement	*pxRoot = pxDoc->CreateRootNode("Symbols", NULL, NULL);
		pxRoot->SetNamespaceDeclaration("http://www.w3.org/1999/xlink","xlink");

		Symbol		*pSymbol = NULL;
		m_pSymbols->Reset();
		while((pSymbol=m_pSymbols->Next())!=NULL)
		{
			AddSymbolNode(pxRoot, pSymbol);
		}
	}
	bool DescribeFeatureTypeHandler::WriteDescribeFeatureType_1_1_0(WebContext* pWebContext, const char* typeName, FeatureClass* pFeatureClass)
	{
		char str[AUGE_NAME_MAX];
		char cache_name[AUGE_NAME_MAX];
		char cache_file[AUGE_PATH_MAX];
		const char* cache_path = pWebContext->GetCacheProtocolPath();
		g_snprintf(cache_name, AUGE_NAME_MAX,"%s_wfs_%s_describe_feauretype_1_1_0", pWebContext->GetService(), typeName);
		auge_make_path(cache_file, NULL, cache_path, cache_name,"xml");

		XElement  *pxNode = NULL;
		XElement  *pxRoot = NULL;
		XDocument *pxDoc = new XDocument();
		pxRoot = pxDoc->CreateRootNode("schema", NULL, NULL);
		pxRoot->SetNamespaceDeclaration("http://www.opengis.net/wfs",NULL);
		pxRoot->SetNamespaceDeclaration("http://www.opengis.net/wfs","wfs");
		pxRoot->SetNamespaceDeclaration("http://www.opengis.net/ows","ows");
		pxRoot->SetNamespaceDeclaration("http://www.opengis.net/gml","gml");
		pxRoot->SetNamespaceDeclaration("http://www.w3.org/1999/xlink","xlink");
		pxRoot->SetNamespaceDeclaration("http://www.w3.org/2001/XMLSchema-instance","xsi");
		pxRoot->SetNamespaceDeclaration("http://www.w3.org/2001/XMLSchema","xsd");		
		pxRoot->SetAttribute("version", "1.1.0", NULL);

		// schema-->import
		XElement* pxImport = pxRoot->AddChild("import", "xsd");
		pxImport->SetAttribute("namespace","http://www.opengis.net/gml", NULL);
		// schema-->complexType
		g_sprintf(str,"%sType", typeName);
		XElement* pxComplexType = pxRoot->AddChild("complexType", "xsd");
		pxComplexType->SetAttribute("name", str, NULL, true);
		// schema-->complexType-->complexContent
		XElement* pxComplexContent = pxComplexType->AddChild("complexContent","xsd");
		// schema-->complexType-->complexContent-->extentsion
		XElement* pxExtentsion = pxComplexContent->AddChild("extentsion", "xsd");
		pxExtentsion->SetAttribute("base","gml:AbstractFeatureType", NULL);
		// schema-->complexType-->complexContent-->extentsion-->sequence
		XElement* pxSequence = pxExtentsion->AddChild("sequence", "xsd");

		GField	*pField  = NULL;
		GFields	*pFields = pFeatureClass->GetFields();
		g_uint count = pFields->Count();
		augeFieldType ftype = augeFieldTypeNone;

		// schema-->complexType-->complexContent-->extentsion-->sequence-->element
		XElement* pxElement = NULL;
		for(g_uint i=0; i<count; i++)
		{
			pField = pFields->GetField(i);
			pxElement = pxSequence->AddChild("element", "xsd");
			const char* fname = pField->GetName();
			const char* utf8_name = auge_encoding_convert("GBK","UTF-8",fname,strlen(fname));
			pxElement->SetAttribute("name",utf8_name, NULL);
			pxElement->SetAttribute("nillable",pField->IsNullable()?"true":"false", NULL);
			pxElement->SetAttribute("minOccurs","0", NULL);
			pxElement->SetAttribute("maxOccurs","1", NULL);
			
			ftype = pField->GetType();
			if(ftype==augeFieldTypeGeometry)
			{
				augeGeometryType gtype = pField->GetGeometryDef()->GeometryType();
				const char* sss = GetOgcGeometryType(gtype);
				g_sprintf(str,"gml:%sPropertyType",sss);
				pxElement->SetAttribute("type",str, NULL);
			}
			else
			{
				g_sprintf(str, "xsd:%s", GetOgcFieldType(pField->GetType()));
				pxElement->SetAttribute("type",str, NULL);
			}

			if(ftype==augeFieldTypeString)
			{
				g_sprintf(str,"%d",pField->GetLength());
				pxElement->SetAttribute("length",str, NULL);
			}
		}

		// schema-->element
		pxElement = pxRoot->AddChild("element", "xsd");
		g_sprintf(str, "%sType", typeName);
		pxElement->SetAttribute("type",str, NULL, true);
		pxElement->SetAttribute("name",typeName, NULL, true);
		pxElement->SetAttribute("substitutionGroup","gml:_Feature", NULL);

		pxDoc->Save(cache_file, pWebContext->GetResponseEncoding(), 1);
		pxDoc->Release();

		return true;
	}
	RESULTCODE CapabilitiesResponse::Write(WebWriter* pWriter)
	{
		if(pWriter==NULL)
		{
			return AG_FAILURE;
		}

		char ims_xlink[AUGE_MSG_MAX];
		g_sprintf(ims_xlink, "http://%s/%s/%s/ims?service=ims",	m_pRequest->GetHost(),
			AUGE_VIRTUAL_NAME,
			m_pRequest->GetUser()); 

		GLogger* pLogger = augeGetLoggerInstance();
		pLogger->Debug(m_path.c_str(), __FILE__, __LINE__);

		Service* pService = NULL;
		EnumService *pServices = NULL;
		ServiceManager* pServiceManager = augeGetServiceManagerInstance(); 

		XElement	*pxNode = NULL;
		XDocument	*pxDoc = new XDocument();
		XElement	*pxRoot = pxDoc->CreateRootNode("IMS_Capabilities", NULL, NULL); 
		pxRoot->SetNamespaceDeclaration("http://www.opengis.net/wms",NULL);
		pxRoot->SetNamespaceDeclaration("http://www.w3.org/1999/xlink","xlink");
		pxRoot->SetNamespaceDeclaration("http://www.w3.org/2001/XMLSchema-instance","xsi");

		// IMS_Capabilities-->Capability
		XElement	*pxCapability = pxRoot->AddChild("Capability", NULL);
		// IMS_Capabilities-->Capability-->Request
		XElement	*pxRequest = pxCapability->AddChild("Request", NULL);


		WEngine* pWEngine = (WEngine*)augeGetWebEngineInstance();
		std::vector<WebHandler*>& handlers = pWEngine->m_handlers;
		std::vector<WebHandler*>::iterator iter;
		for(iter=handlers.begin(); iter!=handlers.end(); iter++)
		{
			WebHandler* handler = *iter;
			// IMS_Capabilities-->Capability-->Request-->GetCapabilities
			XElement	*pxOperation = pxRequest->AddChild("Operation", NULL);
			pxOperation->SetAttribute("name",handler->GetName(), NULL);
			// IMS_Capabilities-->Capability-->Request-->GetCapabilities-->Format
			XElement	*pxFormat = pxOperation->AddChild("Format", NULL);
			// IMS_Capabilities-->Capability-->Request-->GetCapabilities-->Format-->DCPType
			XElement	*pxDCPType = pxOperation->AddChild("DCPType", NULL);
			// IMS_Capabilities-->Capability-->Request-->GetCapabilities-->Format-->DCPType-->HTTP
			XElement	*pxHttp = pxDCPType->AddChild("HTTP", NULL);
			// IMS_Capabilities-->Capability-->Request-->GetCapabilities-->Format-->DCPType-->HTTP-->Get
			XElement	*pxGet = pxHttp->AddChild("Get", NULL);
			// IMS_Capabilities-->Capability-->Request-->GetCapabilities-->Format-->DCPType-->HTTP-->Get-->OnlineResource
			XElement	*pxOnlineResource = pxGet->AddChild("OnlineResource", NULL);
			pxOnlineResource->SetAttribute("xlink:href",ims_xlink, NULL);
			pxHttp = pxDCPType->AddChild("HTTP", NULL);
			// IMS_Capabilities-->Capability-->Request-->GetCapabilities-->Format-->DCPType-->HTTP-->Post
			XElement	*pxPost = pxHttp->AddChild("Post", NULL);
			// IMS_Capabilities-->Capability-->Request-->GetCapabilities-->Format-->DCPType-->HTTP-->Post-->OnlineResource
			pxOnlineResource = pxPost->AddChild("OnlineResource", NULL);
			pxOnlineResource->SetAttribute("xlink:href",ims_xlink, NULL);
		}

		XElement	*pxServices = NULL;
		XElement	*pxService  = NULL;
		pxServices = pxRoot->AddChild("Services", NULL);

		//pServices = pServiceManager->GetServices();
		//pServices->Reset();
		//pServices->Release();
		pServices = pServiceManager->GetServices(m_pUser->GetID());
		pServices->Reset();

		const char* name = NULL;
		while((pService=pServices->Next())!=NULL)
		{
			name = pService->GetName();
			pxService = pxServices->AddChild("Service", NULL);
			pxService->SetAttribute("name", name, NULL);
		}
		pServices->Release();

		int len = 0;
		g_uchar* buffer = NULL;
		pxDoc->WriteToString(&buffer, len, "GBK",0);

		pWriter->WriteHead(m_pRequest->GetMimeType());
		pWriter->Write(buffer, len);
		pWriter->WriteTail();

		pLogger->Trace((g_char*)buffer);

		pxDoc->Close();
		AUGE_SAFE_RELEASE(pxDoc);
		return AG_SUCCESS;
	}