[ggl2-users] Re: filter + select:: Bug or feature? - [ reputation: 4.4 ]

  • From: Guillaume Chauvat <guillaume.chauvat@xxxxxxxxxxxxxx>
  • To: ggl2-users@xxxxxxxxxxxxx
  • Date: Fri, 22 Jun 2012 16:36:28 +0200

Understood, thank you for your help.

I am now faced with a strange problem. I'm obviously wrong somewhere in the
code, but perhaps there is something wrong with the compiler.

I am trying to export a selection of buildings around a place thanks to the
Extrusion Function I sent you some mails ago.


read SHP 'D:/Données/Indicateurs Morphométriques/BD TOPO/buildings.shp' to
buildings;
read SHP 'D:/Données/Indicateurs Morphométriques/BD
TOPO/squares_in_nantes_rgf93.shp' to roi;

zoi = roi filter(roi/gid == 2) select(r | mageometrie =
ST_Extent([ST_Buffer(r/the_geom, 100)]));

intersection = zoi join buildings(z, b | on ST_Intersects(z/mageometrie,
b/the_geom) include b/the_geom, b/Hauteur);

result = intersection select(r | r/Hauteur, truc =
ST_Intersection(r/mageometrie, r/the_geom));

export =[as geometry];
foreach building in result {
    add buildingWithFlatRoofExtrusion(building/truc, building/Hauteur) to
    export;
}

Unfortunately, this returns :
Exception in thread "main" java.io.IOException: Unable to delete file:
C:\Users\gchauvat\AppData\Local\Temp\ggl-temporal334116472884755770.tmp\ggl-temporal4934100457572999836.gtf
    at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:1643)
    at org.apache.commons.io.FileUtils.cleanDirectory(FileUtils.java:1268)
    at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1200)
    at org.gearscape.ggl.runtime.IOUtils.clearTemporalFiles(IOUtils.java:95)
    at gridGen.places_nantaises.main(places_nantaises.java:393)

I was wondering if it has something to do with a compiler error.

Thank you for looking at this.
I send you an image of a small city generated thanks to some ggl2 functions
(are you interested in the scripts?).


Guillaume










2012/6/22 Fernando González <fergonco@xxxxxxxxx>

> It is indeed right. In the first case, the select is not accessing the
> filter result, it is accessing the original "roi" variable and
> "roi/gid" returns a sequence of all gids. Try this and you'll see:
>
> show roi/gid;
>
> In the second case, the select predicate gives an alias "r" to the
> result of the filter and accesses every element in the resulting
> sequence using that alias. Note that this is the only way to access
> the result of the filter since using "roi" references the original
> variable, as in the first case.
>
> Hope it is clear.
>
> On Fri, Jun 22, 2012 at 10:52 AM, Guillaume Chauvat
> <guillaume.chauvat@xxxxxxxxxxxxxx> wrote:
> > Dear ggl2-users,
> >
> > Lets assume roi is an input datasource containing a numeric field called
> > gid. I'm surprised to notice that:
> >
> > show roi filter(roi/gid == 2) select(roi/gid);
> >
> > show roi filter(roi/gid == 2) select(r | r/gid);
> >
> > do not return the same results:
> >
> > [{gid=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]}]
> >
> > [{gid=2}]
> >
> > What's wrong?
> >
> > Thanks a lot for your help.
>
>
>

Attachment: test8.jpg
Description: JPEG image

Other related posts: