Remove symbol properties from layer element in .thuban files
Jan-Oliver Wagner
jan at intevation.de
Wed Jul 27 01:21:26 CEST 2005
On Wed, Jun 29, 2005 at 11:53:45PM +0200, Jan-Oliver Wagner wrote:
> On Mon, Jun 27, 2005 at 06:26:59PM +0200, Jan-Oliver Wagner wrote:
> > I have come to the conclusion that it makes sense
> > to remove symbol properties from layer element in .thuban files:
> > (these are used for the default values)
> >
> > Actually, it seems to be better to have always a
> > classification for a layer and then have
> > a clnull element describing the defaults.
> > Else the situation is a bit redundant. Also, the more
> > complex the description of a symbol becomes the more
> > the layer element is overloaded. The introduction of the
> > size element showed this.
> >
> > Using always a classification would also fix the bug
> > that labels for default (if there is only just a default
> > and no classification) are not stored in the .thuban
> > file.
> >
> > Opinions?
>
> Apparently not. So I will prepare a patch that removes
> the default symbol attributes from layer element in .thuban
> files ...
the attached patch does most of the job.
However, running test_save.py shows an error
that has something to do with postgis stores not
having a method ShapeType ...
I'll try to solve this next.
Best
Jan
--
Jan-Oliver Wagner http://intevation.de/~jan/
Intevation GmbH http://intevation.de/
Kolab Konsortium http://kolab-konsortium.de/
FreeGIS http://freegis.org/
-------------- next part --------------
Index: ChangeLog
===================================================================
RCS file: /thubanrepository/thuban/ChangeLog,v
retrieving revision 1.825
diff -r1.825 ChangeLog
0a1,23
> 2005-07-xx Jan-Oliver Wagner <jan at intevation.de>
>
> * Thuban/Model/classification.py (Classification.TreeItem.build_info):
> Added output of size.
>
> * Thuban/Model/load.py (SessionLoader.start_classification):
> Change attribute 'field' and 'field_type' from obligatory to
> optional to allow empty classes (ie. only with a default=clnull).
>
> * Thuban/Model/save.py (SessionSaver.write_layer): Don't write
> any attributes anymore for the layer element.
> (SessionSaver.write_classification): Even if there is no
> classification field, still write the classification because
> the clnull (default) symbol will not be defined anymore as
> part of the layer element.
>
> * test/test_load.py: ........
>
> * test/test_save.py: ........
>
> * Resources/XML/thuban-1.1.dtd: Make the attributes field
> and field_type of classification optional.
>
Index: Resources/XML/thuban-1.1.dtd
===================================================================
RCS file: /thubanrepository/thuban/Resources/XML/thuban-1.1.dtd,v
retrieving revision 1.3
diff -r1.3 thuban-1.1.dtd
183,184c183,184
< <!ATTLIST classification field CDATA #REQUIRED>
< <!ATTLIST classification field_type CDATA #REQUIRED>
---
> <!ATTLIST classification field CDATA>
> <!ATTLIST classification field_type CDATA>
Index: Thuban/Model/classification.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/Model/classification.py,v
retrieving revision 1.39
diff -r1.39 classification.py
1c1
< # Copyright (c) 2001, 2003 by Intevation GmbH
---
> # Copyright (c) 2001, 2003, 2005 by Intevation GmbH
3a4
> # Jan-Oliver Wagner <jan at intevation.de> (2005)
309a311,317
>
> # Note: Size is owned by all properties, so
> # a size will also appear where it does not
> # make sense like for lines and polygons.
> v = props.GetSize()
> i.append(_("Size: %s") % v)
>
Index: Thuban/Model/load.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/Model/load.py,v
retrieving revision 1.56
diff -r1.56 load.py
527a528,529
> # field and field_type are optional because the classification
> # can also be empty, ie. have only a default.
529,530c531,533
< [AttrDesc("field", True),
< AttrDesc("field_type", True)])
---
> [AttrDesc("field", False),
> AttrDesc("field_type", False)])
>
532a536,537
>
> if field == "": return # no need to set classification column.
Index: Thuban/Model/save.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/Model/save.py,v
retrieving revision 1.45
diff -r1.45 save.py
3c3
< # Jan-Oliver Wagner <jan at intevation.de> (2004)
---
> # Jan-Oliver Wagner <jan at intevation.de> (2004-2005)
294,299d293
<
< lc = layer.GetClassification()
< attrs["stroke"] = lc.GetDefaultLineColor().hex()
< attrs["stroke_width"] = str(lc.GetDefaultLineWidth())
< attrs["fill"] = lc.GetDefaultFill().hex()
<
329,332c323,325
< #
< # there isn't a classification of anything so do nothing
< #
< if field is None: return
---
> if field is not None:
> attrs["field"] = field
> attrs["field_type"] = str(layer.GetFieldType(field))
334,335d326
< attrs["field"] = field
< attrs["field_type"] = str(layer.GetFieldType(field))
Index: test/test_load.py
===================================================================
RCS file: /thubanrepository/thuban/test/test_load.py,v
retrieving revision 1.47
diff -r1.47 test_load.py
204,206c204,210
< <layer shapestore="D1" visible="true"
< stroke="#000000" title="K\xc3\xbcste" stroke_width="1"
< fill="None"/>
---
> <layer shapestore="D1" visible="true" title="K\xc3\xbcste">
> <classification>
> <clnull label="">
> <cldata stroke="#000000" stroke_width="1" fill="None"/>
> </clnull>
> </classification>
> </layer>
296,298c300
< <layer shapestore="D1" visible="true"
< stroke="#000000" title="layer" stroke_width="1"
< fill="None">
---
> <layer shapestore="D1" visible="true" title="layer">
371,372c373,379
< <layer shapestore="D1" visible="false" stroke="#000000"
< title="My Layer" stroke_width="1" fill="None"/>
---
> <layer shapestore="D1" visible="false" title="My Layer">
> <classification>
> <clnull label="">
> <cldata stroke="#000000" stroke_width="1" fill="None"/>
> </clnull>
> </classification>
> </layer>
402c409
< <layer title="cultural_landmark-point" stroke_width="1" shapestore="D813968480" visible="true" stroke="#000000" fill="#000000">
---
> <layer title="cultural_landmark-point" shapestore="D813968480" visible="true">
458,459c465
< <layer shapestore="D138389860" visible="true" stroke="#000000"
< title="My Layer" stroke_width="1" fill="None">
---
> <layer shapestore="D138389860" visible="true" title="My Layer">
476,477c482
< <layer shapestore="D138504492" visible="true" stroke="#000000"
< title="My Layer 2" stroke_width="2" fill="None">
---
> <layer shapestore="D138504492" visible="true" title="My Layer 2">
549,550c554
< <layer shapestore="D1" visible="true" stroke="#000000"
< title="My Layer" stroke_width="1" fill="None">
---
> <layer shapestore="D1" visible="true" title="My Layer">
599,600c603
< <layer shapestore="D4" visible="true" stroke="#000000"
< title="My Layer" stroke_width="1" fill="None">
---
> <layer shapestore="D4" visible="true" title="My Layer">
615,616c618
< <layer shapestore="D2" visible="true" stroke="#000000"
< title="My Layer" stroke_width="1" fill="None">
---
> <layer shapestore="D2" visible="true" title="My Layer">
622a625,629
> <classification>
> <clnull label="">
> <cldata stroke="#000000" stroke_width="1" fill="None"/>
> </clnull>
> </classification>
714,715c721,727
< <layer shapestore="D136170932" visible="true" stroke="#000000"
< title="My Layer" stroke_width="1" fill="None"/>
---
> <layer shapestore="D136170932" visible="true" title="My Layer">
> <classification>
> <clnull label="">
> <cldata stroke="#000000" stroke_width="1" fill="None"/>
> </clnull>
> </classification>
> </layer>
764,765c776
< <layer shapestore="D145265052" visible="true" stroke="#000000"
< title="political" stroke_width="1" fill="#c0c0c0">
---
> <layer shapestore="D145265052" visible="true" title="political">
770a782,786
> <classification>
> <clnull label="">
> <cldata stroke="#000000" stroke_width="1" fill="#c0c0c0"/>
> </clnull>
> </classification>
772,773c788
< <layer shapestore="D145412868" visible="true" stroke="#000000"
< title="landmarks" stroke_width="1" fill="#ffff00">
---
> <layer shapestore="D145412868" visible="true" title="landmarks">
778a794,798
> <classification>
> <clnull label="">
> <cldata size="5" stroke="#000000" stroke_width="1" fill="#ffff00"/>
> </clnull>
> </classification>
Index: test/test_save.py
===================================================================
RCS file: /thubanrepository/thuban/test/test_save.py,v
retrieving revision 1.37
diff -r1.37 test_save.py
159,160c159,166
< <layer title="My Layer" shapestore="D1"
< fill="None" stroke="#000000" stroke_width="1" visible="%s"/>
---
> <layer title="My Layer" shapestore="D1" visible="%s">
> <classification>
> <clnull label="">
> <cldata fill="None" stroke="#000000"
> stroke_width="1"/>
> </clnull>
> </classification>
> </layer>
219,220c225
< <layer title="My Layer" shapestore="D1"
< fill="None" stroke="#000000" stroke_width="1" visible="true">
---
> <layer title="My Layer" shapestore="D1" visible="true">
226a232,237
> <classification>
> <clnull label="">
> <cldata fill="None" stroke="#000000"
> stroke_width="1"/>
> </clnull>
> </classification>
354,355c365
< <layer title="My Layer" shapestore="D1"
< fill="None" stroke="#000000" stroke_width="1" visible="true">
---
> <layer title="My Layer" shapestore="D1" visible="true">
374,375c384
< <layer title="My Layer" shapestore="D1"
< fill="None" stroke="#000000" stroke_width="1" visible="true">
---
> <layer title="My Layer" shapestore="D1" visible="true">
489,490c498,505
< shapestore="D141915644" visible="true"
< stroke="#000000" stroke_width="1" fill="None"/>
---
> shapestore="D141915644" visible="true">
> <classification>
> <clnull label="">
> <cldata fill="None" stroke="#000000"
> stroke_width="1"/>
> </clnull>
> </classification>
> </layer>
552,553c567,574
< shapestore="roads" visible="true"
< stroke="#000000" stroke_width="1" fill="None"/>
---
> shapestore="roads" visible="true">
> <classification>
> <clnull label="">
> <cldata fill="None" stroke="#000000"
> stroke_width="1"/>
> </clnull>
> </classification>
> </layer>
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)