본문 바로가기
GIS

WFS - Operations(3) : Stored Queries

by 드로니뚜벅이 2023. 3. 21.

WFS 서버에서 제공할 수 있는 작업(Operation) 유형에 대해 자세히 알아 보겠습니다.

Operation Option Description
GetCapabilities   지원되는 작업, 매개변수 그리고 사용 가능한 피쳐 타입 목록을 포함하여 서비스에 대한 메타데이터를 검색합니다.
DescribeFeatureType   WFS 인스턴스에서 제공하거나 허용하는 피쳐 유형 및 피쳐 속성의 구조에 대한 설명을 전달합니다.
GetFeature   WFS를 통해 게시된(published) 데이터 저장소에서 선택한 피쳐 인스턴스를 전달합니다.
ListStoredQueries   WFS 인스턴스 내에 저장된 질의(queries) 목록을 전달합니다.
DescribeStoredQueries   WFS 인스턴스 내에 저장된  질의(queries)에 대한 설명을 전달합니다.
GetPropertyValue Optional 일련의 피쳐 인스턴스에 대한 피처 속성 값 혹은 복잡한 피쳐 속성 값의 일부를 검색합니다.
GetFeatureWithLock Optional GetFeature 요청과 유사한 기능을 제공하지만 아마도 후속 업데이트나 변경을 위해 기능을 피쳐를 잠그는 추가 기능입니다.
LockFeature Optional 일련의 피쳐 인스턴스를 잠궈서 잠금이 설정된 동안에는 다른 작업이 데이터를 수정할 수 없도도록 합니다.
Transaction Optional 피쳐 인스턴스와 속성을 수정하거나 삭제할 수 있게 합니다.
CreateStoreadQuery Optional 나중에 클라이언트가 빠르고 쉽게 트리거할 수 있는 쿼리를 생성하고 저장합니다.
DropStoredQuery Optional 이전에 저장된 쿼리를 서버에서 삭제합니다.

짧은 한 줄 URL을 사용하면 저장된 쿼리를 통해 클라이언트 응용프로그램이 원래 여러 줄의 XML로 구성된 쿼리를 호출할 수 있습니다.

저장된 쿼리 표현식은 GeoPropertyName, GetFeature, GetFeatureWithLock 혹은 LockFeature 작업에서 사용할 수 있습니다. 파라미터는 요청된 작업에서 작동하도록 저장된 쿼리에 전달할 수 있습니다.

모든 서버는 식별자를 기반으로 피쳐를 가져오는 저장된 쿼리를 나열, 설명, 그리고 실행하는 기능을 구현해야 합니다. 추가 저장된 쿼리도 제공될 수도 있습니다.

 

ListStoredQueries

현재 WFS 서버에서 유지되고 있는 저장된 쿼리 목록을 반환합니다.

 

Request

ListStoredQueries의 사용 예는 다음과 같습니다.

http://localhost:8080/geoserver/wfs?
request=ListStoredQueries&
version=2.0.0

위 예에서는 서버에서 유지되는 모든 저장된 쿼리 목록을 요청합니다. POST 요청의 예는 다음과 같습니다.

<wfs:ListStoredQueries service='WFS'
 version='2.0.0'
 xmlns:wfs='http://www.opengis.net/wfs/2.0 />

 

Response

응답은 서버에 저장된 각 쿼리의 식별자와 이름을 나타내는 XML 문서입니다. 식별자는 예를 들어 GetFeature 요청에서 STOERDQUERY_ID 파라미터를 통해 저장된 쿼리를 호출할 때 사용됩니다.

<wfs:ListStoredQueriesResponse xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<wfs:StoredQuery id="urn:ogc:def:query:OGC-WFS::GetFeatureById">
<wfs:Title xml:lang="en">Get feature by identifier</wfs:Title>
<wfs:ReturnFeatureType/>
</wfs:StoredQuery>
</wfs:ListStoredQueriesResponse>

 

DescribeStoredQueries

WFS 서버에서 유지 관리하는 각 저장된 쿼리에 대한 자세한 메타데이터를 반환합니다. 특정 쿼리의 ID를 제공하여 개별 쿼리에 대한 설명을 요청할 수 있습니다. ID가 제공되지 않으면 모든 쿼리를 설명합니다.

 

Request

DescribeStoredQueries 사용 예는 다음과 같습니다.

http://localhost:8080/geoserver/wfs?
request=DescribeStoredQueries&
STOREDQUERY_ID=urn:ogc:def:query:OGC-WFS::GetFeatureById&
version=2.0.0

위 예에서는 "urn:ogc:def:query:OGC-WFS::GetFeatureById" ID로 존재하는 저장된 쿼리를 설명합니다. POST 요청은 다음과 같습니다.

<wfs:DescribeStoredQueries
 xmlns:wfs='http://www.opengis.net/wfs/2.0'
 service='WFS'>
 <wfs:StoredQueryId>urn:ogc:def:query:OGC-WFS::GetFeatureById</wfs:StoredQueryId>
</wfs:DescribeStoredQueries>

Response

응답은 STOREDQUERY_ID 파라미터로 지정된 식별자로 지정된 저장된 쿼리를 설명하는 XML 문서입니다.

<wfs:DescribeStoredQueriesResponse xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<wfs:StoredQueryDescription id="urn:ogc:def:query:OGC-WFS::GetFeatureById">
<wfs:Title xml:lang="en">Get feature by identifier</wfs:Title>
<wfs:Parameter name="ID" type="xs:string"/>
<wfs:QueryExpressionText isPrivate="true" language="urn:ogc:def:queryLanguage:OGC-WFS::WFS_QueryExpression" returnFeatureTypes=""/>
</wfs:StoredQueryDescription>
</wfs:DescribeStoredQueriesResponse>

 

CreateStoreQuery

WFS 서버에 저장된 쿼리를 생성합니다. 저장된 쿼리의 정의는 StoredQueryDefinition 파라미터로 인코딩되며 참조용 ID가 부여됩니다.

 

아래 CreateStoredQuery POST 예제는 주어진 관심 영역(${AreaOfInterest}) 내에 있는 피쳐로 topp:states 레이어를 필터링하는 새 저장된 쿼리("myStoredQuery")를 생성합니다.

<wfs:CreateStoredQuery service='WFS' version='2.0.0'
 xmlns:wfs='http://www.opengis.net/wfs/2.0'
 xmlns:fes='http://www.opengis.org/fes/2.0'
 xmlns:gml='http://www.opengis.net/gml/3.2'
 xmlns:myns='http://www.someserver.com/myns'
 xmlns:topp='http://www.openplans.org/topp'>
  <wfs:StoredQueryDefinition id='myStoredQuery'>
    <wfs:Parameter name='AreaOfInterest' type='gml:Polygon'/>
    <wfs:QueryExpressionText
     returnFeatureTypes='topp:states'
     language='urn:ogc:def:queryLanguage:OGC-WFS::WFS_QueryExpression'
     isPrivate='false'>
      <wfs:Query typeNames='topp:states'>
        <fes:Filter>
          <fes:Within>
            <fes:ValueReference>the_geom</fes:ValueReference>
             ${AreaOfInterest}
          </fes:Within>
        </fes:Filter>
      </wfs:Query>
    </wfs:QueryExpressionText>
  </wfs:StoredQueryDefinition>
</wfs:CreateStoredQuery>

 

DropStoredQuery

CreateStoredQuery 작업으로 이전에 생성된 저장된 쿼리를 삭제하는 작업입니다. 요청은 삭제할 쿼리의 ID를 받습니다.

다음 예는 myStoredQuery ID를 가진 저장된 쿼리를 삭제합니다.

http://example.com/geoserver/wfs?
  request=DropStoredQuery&
  storedQuery_Id=myStoredQuery

 

 

참고사이트

 

 

'GIS' 카테고리의 다른 글

DEGREE(도, ° ) vs. RADIAN(라디안)  (0) 2023.04.12
cs2cs command  (0) 2023.04.11
좌표 정의 및 좌표계  (0) 2023.04.05
WFS - Operations(2) : GetPropertyValue, DescribeFeatureType  (0) 2023.03.21
WFS - Operations(1) : GetFeature, GetCapabilites  (0) 2023.03.21