[postgis-users] Update the geom of a table WHERE "i" is an even number

Nicolas Gillet - MARKET-IP nicolas.gillet at market-ip.com
Tue Oct 13 02:37:08 PDT 2009


Hello Daniel,

I am not very sure of your question but

What about the modulo (%) operator ?

- "WHERE i%10 = 0"
This will keep only rows where the rest of division of i by 10 is 0.
e.g. 
15 % 10 = 5 KO (15 / 10 = 1 rest 5)
30 % 10 = 0 OK (30 / 10 = 3 rest 0)
23 % 10 = 2 KO (22 / 10 = 2 rest 3)
...

Regards,

Nicolas Gillet


-----Message d'origine-----
De : postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] De la part de Daniel
Grum
Envoyé : mardi 13 octobre 2009 11:18
À : PostGIS Mailing-List
Objet : [postgis-users] Update the geom of a table WHERE "i" is an even
number

Hi,

I need a possibilty that a table "wald_by" will be updatet WHERE my 
counter "i" is an even number?!

UPDATE wald_by
SET the_geom = the_geom - 
ST_Intersection(poly.the_geom,ST_Expand(pt.the_geom, 2000))
FROM public.wald_by poly, public.holzfaeller pt, public.runden i
WHERE poly.the_geom && ST_Expand(pt.the_geom, 2000) AND pt.style=2 AND* 
i/5=2*;

i/5=2 ???--> That mean: this UPDATE should be done if i=[10, 20, 30, 
40...] !!!!
And WHERE  "i" is another number nothing should be done-->the_geom=the_geom

the_geom is a forest area where forest will be cut, and after 10 rounds 
the area of the cut down area should be deducted from the original 
forest area-->the forest will be smaller after 10 rounds!
There are two modes of lumberjacks, the one mode(pt.style=1) he cut down 
the wood regenerative and the other one  is clearing the forest 
completely-->the area should be deducted.

"i" will be stored every round in one table: "runden" and every round 
this SQL will be done:
UPDATE runden SET i=i+1;

Are there any ideas?

--daniel
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users




More information about the postgis-users mailing list