Subject: [Thuban-list] Localizing Thuban, and more...

From: Cherkashin Evgeny <[email-masked]>
Date: Wed, 22 Jan 2003 20:28:54 +0800

Hi!

I'm head of an scientific project "Constructing an intelligent GIS", 
project "Angara" (103E, 53N, Irkutsk) which is sponsored of Russian 
Foundation of Fundamental (Pure) Research. Our aim is to construct 
programmatical means of development of Decision Support Systems of 
reginal resources control.

A year ago I've decided to construct a new GIS on the base of Python and 
wxWindows. But due to some organizing problems the project did not 
started (we developed some scientific aspects of the project).

Not so long time ago I've found the Thuban project. Thst's it, I dreamed 
at nigth. People, wery good work. I decided to develop the project further.
My personal itch in the development is as follows:
1. Adaptation of the GIS-viewer to Russian locale. (DONE yestarday 
partially).
2. Include GDAL-directed access to the GIS.
3. Introduce some spatial data treatenment software, that we have 
developed (Database Access using XML-specs, City road net reconstruction).
4. After introducing in the Python langage some means of logical 
inference, the system can do some AI (Automatical model construction of 
a class of models on the base of data and investigation aim description).
5. I can make an mirror site of the Thuban site.

Now I send a patch (durty), which contains the localization and change 
of the setup.py procedure.

The localization allows me to use russian file names and titles. It 
should be tested by You wether it still works or not.

The setup.py was changed (the changes are not intended to be in the 
distribution directly):
1. To build the wx module on the base of preinstalled development 
package of the wxPython library. The library is now can be downloaded 
from www.wxPyhon.org with the library. So, developer are note required 
to compile wxWindows itself.
2. I placed Proj-4.5 sources in "local" directory.

Thanks for Your help to our scientific investigation. You can (should) 
place also the sign: "The project is partially sponsored by Russian 
Foundation of Fundamental Research, grants No 01-07-90411, 02-07-06013, 
   02-05-65054, 02-07-90113, http://www.rfbr.ru"

Big warm Gruss aus Sibirien,
Ewgenij Tscherkashin (in German transcription)

P.S. The diff file is in the attachment.
diff -ru old/Thuban/Model/layer.py new/Thuban/Model/layer.py
--- old/Thuban/Model/layer.py	2002-08-29 01:36:28.000000000 +0800
+++ new/Thuban/Model/layer.py	2003-01-22 00:45:58.000000000 +0800
@@ -105,7 +105,8 @@
     """
 
     def __init__(self, title, filename, projection = None,
-                 fill = None, stroke = _black, stroke_width = 1, visible = 1):
+                 fill = None, stroke = _black, stroke_width = 1, visible = 1, 
+                 filename_encoding = "latin-1", title_encoding="latin-1"):
         """Initialize the layer.
 
         title -- the title
@@ -131,6 +132,8 @@
         self.fill = fill
         self.stroke = stroke
         self.stroke_width = stroke_width
+        self.filename_encoding=filename_encoding
+        self.title_encoding=title_encoding
         self.shapefile = None
         self.shapetree = None
         self.open_shapefile()
diff -ru old/Thuban/Model/load.py new/Thuban/Model/load.py
--- old/Thuban/Model/load.py	2002-08-23 22:04:32.000000000 +0800
+++ new/Thuban/Model/load.py	2003-01-22 00:57:58.000000000 +0800
@@ -138,13 +138,21 @@
         object and bind it to self.aLayer.
         """
         title = attrs.get((None, 'title'), "")
+        title_encoding = attrs.get((None, 'title_encoding'),  "latin-1")
+        if title_encoding  != "latin-1":
+            title = title.encode(title_encoding)
         filename = attrs.get((None, 'filename'), "")
+        filename_encoding = attrs.get((None, 'filename_encoding'), "latin-1")
+        if filename_encoding != "latin-1":
+            filename = filename.encode(filename_encoding)
         filename = os.path.join(self.directory, filename)
         fill = parse_color(attrs.get((None, 'fill'), "None"))
         stroke = parse_color(attrs.get((None, 'stroke'), "#000000"))
         stroke_width = int(attrs.get((None, 'stroke_width'), "1"))
         self.aLayer = layer_class(title, filename, fill = fill,
-                                  stroke = stroke, stroke_width = stroke_width)
+                                  stroke = stroke, stroke_width = stroke_width,
+                                  filename_encoding=filename_encoding,
+                                  title_encoding=title_encoding)
     start_dispatcher['layer'] = "start_layer"
 
     def end_layer(self, name, qname):
diff -ru old/Thuban/Model/save.py new/Thuban/Model/save.py
--- old/Thuban/Model/save.py	2002-08-23 22:04:22.000000000 +0800
+++ new/Thuban/Model/save.py	2003-01-22 01:10:08.000000000 +0800
@@ -92,8 +92,15 @@
     def write_header(self):
         """Write the XML header"""
         write = self.file.write
-        write('<?xml version="1.0" encoding="UTF-8"?>\n')
-        write('<!DOCTYPE session SYSTEM "thuban.dtd">\n')
+        try: # of cause this is supposition
+               # Everybuddy like to work with local encoding, and, hence,
+               # they write XMLs in it.
+            import locale
+            xml_enc=locale.getdefaultlocale()[1]
+        except ImportError:
+            xml_locale="UTF-8"
+        write('<?xml version="1.0" encoding="%s"?>\n' % xml_enc)
+        #write('<!DOCTYPE session SYSTEM "thuban.dtd">\n')	# issues error - invalid URL thuban.dtd
 
     def write_session(self, session, attrs = None, namespaces = ()):
         """Write the session and its contents
@@ -158,6 +165,8 @@
             attrs = {}
         attrs["title"] = layer.title
         attrs["filename"] = relative_filename(self.dir, layer.filename)
+        attrs["filename_encoding"] = layer.filename_encoding
+        attrs["title_encoding"] = layer.title_encoding
         attrs["stroke_width"] = str(layer.stroke_width)
         fill = layer.fill
         if fill is None:
diff -ru old/Thuban/UI/mainwindow.py new/Thuban/UI/mainwindow.py
--- old/Thuban/UI/mainwindow.py	2002-10-23 22:45:28.000000000 +0800
+++ new/Thuban/UI/mainwindow.py	2003-01-22 00:56:34.000000000 +0800
@@ -356,7 +356,12 @@
         if dlg.ShowModal() == wxID_OK:
             filename = dlg.GetPath()
             title = os.path.splitext(os.path.basename(filename))[0]
-            layer = Layer(title, filename)
+            try:
+                import locale
+                sys_locale=locale.getdefaultlocale()[1]
+            except ImportError:
+                sys_locale="latin-1"
+            layer = Layer(title, filename, filename_encoding=sys_locale, title_encoding=sys_locale)
             map = self.canvas.Map()
             has_layers = map.HasLayers()
             try:
diff -ru old/setup.py new/setup.py
--- old/setup.py	2002-10-23 22:45:58.000000000 +0800
+++ new/setup.py	2003-01-22 19:51:26.000000000 +0800
@@ -74,15 +74,15 @@
     #
     
     # Directories where Proj4 is installed
-    proj4_prefix = r"D:\cygwin\home\user\proj-4.4.3\src"
+    proj4_prefix = r"proj-4.4.5\src" # I've installed it locally
     proj4_incdir =  proj4_prefix
     proj4_libdir =  proj4_prefix
     proj4_lib = "proj_i"
 
     # Define include and lib directories for wxWindows and 
-    wx_prefix = r"D:\wx230"
+    wx_prefix = r"C:\Python22" # when downloaded delel package of wxPython
     wx_inc =  os.path.join(wx_prefix, "include")
-    wx_lib =  os.path.join(wx_prefix, "lib") 
+    wx_lib =  os.path.join(wx_prefix, "libs") # this change I'm not shure, could be ignored
 
     #
     # Unless you use a wxPython version other than 2.3.1, you probably
@@ -129,7 +129,7 @@
     
     wx_incdirs = [wx_inc]
     wx_libdirs = [wx_lib]
-    wx_libs = ["wx23_1h"]
+    wx_libs = ["wxmsw240h"]    # "Test" of new build of wxPython 
     wx_libs = wx_libs + ['kernel32', 'user32', 'gdi32', 'comdlg32',
                          'winspool', 'winmm', 'shell32', 'oldnames',
                          'comctl32', 'ctl3d32', 'odbc32', 'ole32', 'oleaut32',

---

From: Jan-Oliver Wagner <[email-masked]>
Date: Tue, 28 Jan 2003 11:32:51 +0100

> 1. Adaptation of the GIS-viewer to Russian locale. (DONE yestarday 

Your patch workes around the problem that we did not
incorporate real i18n support.
I've started better support for i18n yesterday (due to your
email :-). Primary aims should be to have gettext support
and unicode-clean internal use of strings.
All this will take some time of course.

> 2. Include GDAL-directed access to the GIS.

This would be a great improvement! Please let this
mailing list know on your progress, questions etc.

Best

	Jan
-- 
Jan-Oliver Wagner               http://intevation.de/~jan/

Intevation GmbH	              	     http://intevation.de/
FreeGIS	                               http://freegis.org/