Configuration example

Configuration example

<config xmlns="http://software.in2p3.fr/lavoisier/config.xsd" version="14">
    <view name="parks_wfs">
        <info>
            <category>demo</category>
        </info>
        <connector type="HTTPConnector">
            <parameter name="url">https://download.data.grandlyon.com/wfs/grandlyon?SERVICE=WFS&amp;REQUEST=GetFeature&amp;version=1.1.0&amp;TYPENAME=pvo_patrimoine_voirie.pvoparking</parameter>
        </connector>
        <processors>
            <processor type="TransformProcessor" match="//*">
                <parameter name="template" eval="document('demo/wfs.xml')"/>
            </processor>
            <processor type="InsertProcessor" match="/parks/park/coordinates[text()]">
                <parameter name="nodes" eval="new_attribute('lat', substring-before(text(),' ')) | new_attribute('lng', substring-after(text(),' '))"/>
            </processor>
        </processors>
    </view>

    <view name="parks">
        <info>
            <category>demo</category>
        </info>
        <connector type="HTTPConnector">
            <parameter name="url">https://download.data.grandlyon.com/kml/grandlyon/?request=layer&amp;typename=pvo_patrimoine_voirie.pvoparking</parameter>
        </connector>
        <serializer type="ZipSerializer"/>
        <processors>
            <processor type="TransformProcessor" match="//*">
                <parameter name="template" eval="document('demo/kml.xml')"/>
            </processor>
            <processor type="InsertProcessor" match="/parks/park/coordinates[text()]">
                <parameter name="nodes" eval="new_attribute('lat', substring-after(text(),',')) | new_attribute('lng', substring-before(text(),','))"/>
            </processor>
        </processors>
        <cache type="FileCache">
            <trigger type="ViewCreatedTrigger" ignore-during="PT1H"/>
            <trigger type="ViewNotifiedTrigger"/>
        </cache>
    </view>

    <view name="park">
        <info>
            <category>demo</category>
        </info>
        <argument name="destination" path-format="none"/>
        <argument name="distance" path-format="none">400</argument>
        <variable name="angle" eval="$distance * 360 div 40075000"/>
        <connector type="HTTPConnector">
            <parameter name="url" eval="concat('http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&amp;address=', translate($destination,' ','+'))"/>
        </connector>
        <validator type="PathValidator">
            <parameter name="path">/GeocodeResponse/result</parameter>
            <parameter name="message" eval="concat('Unknown location: ', $destination)"/>
        </validator>
        <processors xmlns:math="http://exslt.org/math">
            <processor type="ElementToAttributeProcessor" match="/GeocodeResponse/result/geometry/location"/>
            <processor type="InsertProcessor" match="/GeocodeResponse/result/geometry/location">
                <parameter name="nodes" eval="view('parks')"/>
            </processor>
            <processor type="InsertProcessor" match="/GeocodeResponse/result/geometry/location/parks/park/coordinates">
                <parameter name="nodes" eval="new_attribute('Distance', math:sqrt(math:power(ancestor::location/@lat - @lat, 2) + math:power(ancestor::location/@lng - @lng, 2)))"/>
            </processor>
            <processor type="RemoveProcessor" match="/GeocodeResponse/result/geometry/location/parks/park[coordinates/@Distance &gt; $angle]"/>
        </processors>
        <pre-renderers>
            <title>'Car Park Coordinates'</title>
            <field>/GeocodeResponse/result/geometry/location/@lat</field>
            <field>/GeocodeResponse/result/geometry/location/@lng</field>
            <row foreach="/GeocodeResponse/result/geometry/location/parks/park/coordinates">
                <column>ancestor::park/name</column>
                <column label="Latitude">(round(@lat*100000) div 100000)</column>
                <column label="Longitude">(round(@lng*100000) div 100000)</column>
                <column unit="degrees">@Distance</column>
            </row>
        </pre-renderers>
        <renderers>
            <renderer type="JSONRenderer">
                <parameter name="text_as_pair">false</parameter>
            </renderer>
            <renderer type="CsvRenderer">
                <parameter name="separator">;</parameter>
            </renderer>
            <renderer type="DefaultRenderer">
                <parameter name="template">html/parking.html</parameter>
            </renderer>
            <renderer type="HTMLRenderer">
                <parameter name="template">html/parking.html</parameter>
            </renderer>
            <renderer type="ChartRenderer">
                <parameter name="axis">polar</parameter>
            </renderer>
        </renderers>
    </view>
</config>