#MAPSERVER IRC Log - 2009-11-15

For logs after Feb 3, 2007, all times are GMT-8. Prior logs are GMT-9.
Back to Logs
04:21:40 ue: jose, yes
06:22:38 jose: ue, How?
06:32:34 jose: Hi can I create a layer...but set different color for each id?
06:32:42 jose: I have a view and I did a layer...so now..i want display it using different color for each id..because this id say the type of points.
07:05:58 ue: jose, here ?
07:07:39 ue: ok, so to answer your question, if there not so many types you can create a class+style for each using expressions: http://mapserver.org/mapfile/class.html
07:07:40 sigabrt: Title: CLASS MapServer 5.4.2 documentation ( at mapserver.org )
07:09:17 ue: if you have like 100 rows with 100 diff color values, you can create a "color" field and then feed it to as a column name to style->color
07:12:55 jose: but I need to set it...for each row...or it can be do automatic?
07:15:05 ue: how many "types" you have ?
07:15:50 ue: or "type of the points"
07:16:43 jose: Oh...that is it the problem...now I have 2 different id's in database and I want coloring it with different color, but I don't know how many I will have after...insertions
07:17:20 ue: ok ... so for every case you create a CLASS http://mapserver.org/mapfile/class.html
07:17:24 sigabrt: Title: CLASS MapServer 5.4.2 documentation ( at mapserver.org )
07:17:29 ue: so you need to create 2 classes
07:17:40 ue: one that has an expression like : [id] = 1
07:17:52 jose: and if someone insert new data I will need to create another class?
07:17:54 ue: and this class will have a style with color 0 0 0 ( as example )
07:18:05 jose: or update the previous one?
07:18:15 ue: and second class with an expression like [id] = 2
07:18:19 ue: and color 255 255 255
07:18:59 ue: think of class as logic, it takes one row checks against an expression
07:19:06 ue: and set a proper color
07:19:57 jose: I understand your advice....but the problem is that I will update this class for every new insertions, ok?:??
07:20:14 ue: no you don't update your class
07:20:23 ue: no matter how many rows you have
07:20:39 ue: they are all checked against your expression
07:21:06 jose: and if a new row inserted has id = 3?
07:21:26 jose: and if it has id = 1000
07:21:27 jose: ?
07:21:35 ue: don't check for id
07:21:38 ue: create a column
07:21:43 ue: like ... type
07:21:58 ue: that has values for example 1 or 2
07:22:17 ue: and in expression check against type
07:22:28 ue: if you have 1000 rows with 1000 different colors
07:22:32 jose: ok, ue...but I want coloring rows looking the id
07:22:52 jose: ok
07:22:58 ue: why do you want that ?
07:23:06 jose: let me explain
07:24:00 jose: I have a table that stored informations about biological surveys called strobs this table has a id and a foregie
07:25:00 jose: and a foreign key that represent the id of the survey
07:25:21 ue: and how many types of surveys there are in general ?
07:25:33 jose: I want coloring lookin by this foreign key..so the observations will be coloring according their survey
07:26:00 jose: hum....
07:26:04 jose: types?
07:26:38 ue: whats a "foregie" ?
07:26:57 jose: the foreign key does not represent the type, but the survey with its informations like the responsible researcher, etc
07:27:04 jose: sorry foreign
07:27:15 ue: so it's like this:
07:27:19 ue: 1 | 1
07:27:23 ue: 2 | 1
07:27:25 ue: 3 | 1
07:27:28 ue: 4 | 2
07:27:41 ue: and you want to color based on second argument ?
07:27:46 jose: yes
07:28:09 ue: and how many distinct "of second argument" you have
07:28:14 ue: in this case we have 2
07:28:50 ue: let's give you foreign key a name ... let's call it "type"
07:28:56 ue: so you have id and type
07:29:02 ue: and you want to color based on type
07:29:02 jose: now I have only two different survey inserted in database, but new surveys can be inserted and new id's ( second column ) will appear
07:29:37 jose: like 3 , 4 , 5 ,6.....
07:29:41 ue: so you need to have as many classes as many "types" you have
07:29:46 ue: and for every class define a proper color color
07:29:49 ue: they can be integers
07:29:52 ue: or string does not matter
07:29:59 ue: then just create a class with expression
07:30:03 ue: [type] = 1
07:30:06 ue: and color 0 0 0
07:30:20 jose: I need to know how many id I have...
07:30:27 ue: and now all surveys with type = 1 will be colored black
07:31:07 ue: ofcourse you need to know that because you need to set colors to them : )
07:31:22 ue: BUT not how many ids
07:31:36 ue: but how many DISTINCT "TYPE" values
07:31:54 ue: so you can have 1 million records of surveys
07:31:58 jose: Hum...but I don't know this...
07:31:58 ue: with 10 diff types
07:32:07 jose: each survey is new type
07:32:35 ue: k, then on what criteria you want to color them ?
07:32:48 ue: or you just want a distinct color for each survey ?
07:33:03 jose: based in survey,,each survey should be colored with one color...
07:33:09 jose: yes
07:33:24 jose: distinct color for each survey
07:33:54 jose: but how new surveys can be insert I don't know how many surveys I have....
07:35:00 ue: as a solution you could make the foloowing select statement
07:35:17 ue: id, type, to_hex( id )
07:35:30 ue: and then in mapserver do something like this:
07:35:49 ue: COLOR
07:35:54 ue: COLOR [color]
07:36:05 ue: you can set a color based on the atribute
07:36:44 ue: general is create a "color" for every row on insert and then just pass it to mapserver
07:36:48 ue: *idea
07:36:59 ue: or on the fly as I suggested earlier
07:37:44 jose: but what do I do with to_hex( id )??
07:39:04 ue: it just converts your integer id to a hex that represents a color ( not tested )
07:39:30 jose: hum... and in COLOR i put this value
07:39:38 jose: COLOR [to_hex( id )]?
07:39:42 ue: no
07:39:57 ue: for test
07:39:59 jose: no?
07:40:09 ue: create a color column in your database
07:40:15 ue: and fill it will color values
07:40:28 jose: in hex?
07:40:28 ue: like ... 0 0 0, 255 0 0
07:40:46 ue: Never tried it, try "0 0 0" representation first
07:40:57 jose: ok
07:41:03 ue: and in mapserver just specify the column name in square brakets
07:41:08 ue: COLOR [color]
07:41:34 jose: it will get the color table and apply a color to rows?
07:41:43 ue: yes
07:41:53 jose: hum....nice ue
07:41:57 jose: I will try it
07:42:04 jose: thank you very much
07:42:08 ue: np
07:42:11 jose: I save my day...hehehehe
07:42:27 jose: can I write ti using SDL?
07:42:34 jose: or only with mapfile?
07:42:54 ue: Don't know, I don't use SDL
07:42:59 jose: ok
07:43:05 jose: I will use mapfiles
07:43:08 jose: thx
07:43:12 ue: try with mapfiles first
07:43:15 ue: yep