2

I'm trying to create a layer from a PostGIS table with REST api, I can create the layer but couldn't add the time dimension.

I can configure the dimension in the interface and I did try to get the feature description but no dimensions infomation:

<layer>
    <name>focos</name>
    <type>VECTOR</type>
    <defaultStyle>
        <name>point</name>
        <atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/styles/point.xml" type="application/xml"/>
    </defaultStyle>
    <resource class="featureType">
        <name>focos</name>
        <atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://localhost:8080/geoserver/rest/workspaces/terrama/datastores/view_focos13postgisstore/featuretypes/focos.xml" type="application/xml"/>
    </resource>
    <attribution>
        <logoWidth>0</logoWidth>
        <logoHeight>0</logoHeight>
    </attribution>
</layer>

Solution: This is the xml model I'm using to do this.

<featureType>
    <name>layer_name</name>
    <metadata>
        </entry>
        <entry key="time">
            <dimensionInfo>
                <enabled>true</enabled>
                <attribute>time_attribute</attribute>
                <presentation>CONTINUOUS_INTERVAL</presentation>
                <units>ISO8601</units>
                <defaultValue>
                    <strategy>MAXIMUM</strategy>
                </defaultValue>
            </dimensionInfo>
        </entry>
    </metadata>
</featureType>
2

Just enable it with the UI once, and check how the layer and the attached resource get modified (I believe you'll find the change in the resource). Then repeat the same using the REST API.

This approach is valid for any configuration that you can carry on with the UI.

1

I had the same need, I solved it in python with gsoncig

https://github.com/boundlessgeo/gsconfig

My code :

from geoserver.catalog import Catalog
cat = Catalog("http://localhost:8080/geoserver/rest/", "admin", "geoserver")
coverage = cat.get_resource_by_url("http://localhost:8080/geoserver/rest/workspaces/test1/coveragestores/netCDFupload/coverages/CHARGE.xml")
from geoserver.support import DimensionInfo
timeInfo = DimensionInfo("time", "true", "LIST", None, "ISO8601", None)
elevationInfo = DimensionInfo("elevation", "true", "LIST", None, "EPSG:5030", None)
coverage.metadata = ({'time': timeInfo, 'elevation': elevationInfo})
cat.save(coverage)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.