Anjo,

Great to hear that your view is working.  To get the overlay to work, try 
replacing the "source" and "source-layer" values with the name of your 
view.  So, changing "grade_i_buildings" to "condition"

Cheers,

Dennis

On Tuesday, May 1, 2018 at 11:34:50 AM UTC-7, Anjo Weichbrodt wrote:
>
> Hi Dennis,
>
> Thank you so much for your answer I really appreciate it.
> I managed to create a view which actually finds my resource labeled with 
> good. I called the view *condition*:
>
>
> -- object: public.condition | type: VIEW --
> -- DROP VIEW IF EXISTS public.condition CASCADE;
> CREATE VIEW public.condition
> AS 
> SELECT row_number() OVER () AS gid,
>     mv.tileid,
>     mv.resourceinstanceid,
>     mv.nodeid,
>     mv.geom,
>     (name_tile.tiledata ->> '663c3a7c-44d2-11e8-b144-028e6def3b89'::text) 
> AS name,
>     'National Monument' AS protection
>    FROM ((mv_geojson_geoms mv
>      LEFT JOIN tiles type_tile ON ((mv.resourceinstanceid = type_tile.
> resourceinstanceid)))
>      LEFT JOIN tiles name_tile ON ((mv.resourceinstanceid = name_tile.
> resourceinstanceid)))
>   WHERE (((type_tile.tiledata ->> '663c3aab-44d2-11e8-b144-028e6def3b89'::
> text) = '5c459cec-0e3f-4f5f-99e5-e4608530508b'::text) AND 
> ((name_tile.tiledata 
> ->> '663c3a7c-44d2-11e8-b144-028e6def3b89'::text) IS NOT NULL));
> -- ddl-end --
> ALTER VIEW public.condition OWNER TO postgres;
> -- ddl-end --
>
> but then I have trouble creating an overlay which actually represents the 
> queried polygons (step 3).
>
> Should I just replace "grade_i_buildings" with national_monument?
> How does this relates to the view created in step 2.
>
> Thanks for your help,
> Anjo
>
> On Sunday, April 29, 2018 at 9:00:06 PM UTC-4, Dennis Wuthrich wrote:
>>
>> Hi Anjo,
>>
>> Yes, you can style resources based on concept values.  Here are the steps:
>>
>> 1. Using a PostgreSQL tool (like PGAdmin, Navicat, or the command line) 
>> confirm that Arches has loaded a materialized view called 
>> mv_geojson_geoms.  This view collects all the geometries for all resource 
>> model in Arches.  It includes the instance id, geometry, and node id for 
>> every resource instance for every model in Arches.  If your version of 
>> Arches doesn't have it, it looks like this:
>>
>> SELECT t.tileid,
>>     t.resourceinstanceid,
>>     n.nodeid,
>>     
>> (st_transform(st_setsrid(st_geomfromgeojson(((json_array_elements((((t.tiledata)::json
>>  
>> -> (n.nodeid)::text) -> 'features'::text)) -> 'geometry'::text))::text), 
>> 4326), 900913))::geometry(Geometry,900913) AS geom
>>    FROM (tiles t
>>      LEFT JOIN nodes n ON ((t.nodegroupid = n.nodegroupid)))
>>   WHERE ((( SELECT count(*) AS count
>>            FROM jsonb_object_keys(t.tiledata) 
>> jsonb_object_keys(jsonb_object_keys)
>>           WHERE (jsonb_object_keys.jsonb_object_keys IN ( SELECT 
>> (n_1.nodeid)::text AS nodeid
>>                    FROM nodes n_1
>>                   WHERE (n_1.datatype = 
>> 'geojson-feature-collection'::text)))) > 0) AND (n.datatype = 
>> 'geojson-feature-collection'::text))
>>
>>
>>
>> 2. You will write a view that references mv_geojson_geoms to identify (in 
>> your case) all instances where the condition type is not null.  Here is an 
>> example of a view that finds all buildings with "Grade I" protection type:
>>
>> SELECT row_number() OVER () AS gid,
>>     mv.tileid,
>>     mv.resourceinstanceid,
>>     mv.nodeid,
>>     mv.geom,
>>     (name_tile.tiledata ->> '677f303d-09cc-11e7-9aa6-6c4008b05c4c'::text) 
>> AS name,
>>     'Grade I Listed Building' AS protection
>>    FROM ((mv_geojson_geoms mv
>>      LEFT JOIN tiles type_tile ON ((mv.resourceinstanceid = 
>> type_tile.resourceinstanceid)))
>>      LEFT JOIN tiles name_tile ON ((mv.resourceinstanceid = 
>> name_tile.resourceinstanceid)))
>>   WHERE (((type_tile.tiledata ->> 
>> '4ca32698-fa12-11e6-9e3e-026d961c88e6'::text) = 
>> 'bc908dbc-45ff-426c-8713-f622907730ab'::text) AND ((name_tile.tiledata ->> 
>> '677f303d-09cc-11e7-9aa6-6c4008b05c4c'::text) IS NOT NULL))
>>
>> A few things to note here:
>> a. the type_tile.tiledata ->> 
>> ''4ca32698-fa12-11e6-9e3e-026d961c88e6'::text   is used to identify the 
>> concept node that you are interested in.  In your case, this would be the 
>> id of the Condition Type node in your model.  You can use the json 
>> representation of the your model (e.g.: export your model and use a text 
>> editor to open it) to find the node id
>>
>> b. the = 'bc908dbc-45ff-426c-8713-f622907730ab'::text  is used to 
>> identify the id of the concept you want to match.  In your case this would 
>> be the id of the concept you want to match (e.g.: "good").  This value may 
>> be in the model json that you used to find the concept id.  Or you can use 
>> the concepts.json file that came with the mapping file that you used to 
>> import data into Arches.  (note that you can re-create this file by going 
>> to your resource model in Arches Designer, click on manage, and select 
>> create mapping file)
>>
>> c. In this example, the name_tile.tiledata is used to identify the node 
>> in the model that you use to name your instance. 
>>  
>>
>> 3.  Once you have the view working, you can create a layer using Arches 
>> built-in map server.  Here's an example of a simple json configuration for 
>> the view:
>>
>> {
>> "type": "vector",
>> "name": "Grade I Buildings",
>> "layers": [{
>> "id": "grade_i_buildings",
>> "type": "circle",
>>       "minzoom": 11,
>> "maxzoom": 21,
>> "source": "grade_i_buildings",
>> "source-layer": "grade_i_buildings",
>> "layout": {
>> "visibility": "visible"
>> },
>> "paint": {
>> "circle-radius": {
>>             "stops": [
>>                 [11, 2],
>>                 [15, 8],
>>                 [21, 50]
>>             ]
>>         }
>> ,
>> "circle-color": "rgba(58, 171, 209,0.25)",
>> "circle-stroke-color": "rgb(58, 171, 209)",
>>           "circle-stroke-width": 1
>> }
>> }],
>> "config": {
>> "provider": {
>> "class": "TileStache.Goodies.VecTiles:Provider",
>> "kwargs": {
>> "dbinfo": {
>> "host": "localhost",
>> "user": "postgres",
>> "password": "postgis",
>> "database": "her_lincoln",
>> "port": "5432"
>> },
>> "simplify": 0.5,
>> "queries": [
>> "select gid as __id__, name as __name__, geom as __geometry__ from 
>> grade_i_buildings"
>> ]
>> }
>> },
>> "allowed origin": "*",
>> "compress": true,
>> "write cache": false
>> }
>> }
>>
>> You can add this layer to Arches as an overlay using the following 
>> command:
>>
>> python manage.py packages -o add_tileserver_layer -t 
>> ~dwuthrich/arches/packages/lincoln_release/map_layers/tile_server/overlays/grade_i_buildings/grade_i_buildings.json
>>  
>> -n "Grade I Buildings"
>>
>> (obviously, you'll need to replace this path and file name in this 
>> example with your own path/file)
>>
>>
>> 4.  You can now go to Arches map manager, navigate to overlays, and view 
>> your layer.  Note that you can click on the "service styling" tab and then 
>> click on the black area to see the json used to style your data.  If you 
>> copy this json, you can paste it into any basemap (or other overlay) style 
>> in Arches.  In this way, you could automatically add your styled data to a 
>> basemap, or aggregate multiple overlays into a single overlay or basemap.
>>
>>
>> I hope this helps.
>>
>> Cheers,
>>
>> Dennis
>>
>>
>> On Friday, April 27, 2018 at 12:31:45 PM UTC-7, Anjo Weichbrodt wrote:
>>>
>>> Hi,
>>>
>>> I would like to represent geometries of resources in different colors 
>>> depending on their attributes.
>>> Example: there is the resource "Wall" which has the "Condition Type"s 
>>> *good, 
>>> fair, poor*. Is it possible to represent all walls with *good* 
>>> condition green, *fair* condition orange and *poor* condition red?
>>>
>>> Thank you!
>>> Anjo
>>>
>>

-- 
-- To post, send email to archesproject@googlegroups.com. To unsubscribe, send 
email to archesproject+unsubscr...@googlegroups.com. For more information, 
visit https://groups.google.com/d/forum/archesproject?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Arches Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to archesproject+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to