Hi list,
Here is my current design and a technical discussion. Any feedback is
appreciated. Please ignore if you don't want to peak under the hood.
Background material:
=============
1) Regular Expressions
http://en.wikipedia.org/wiki/Regular_expression
2) Cartesian Coordinates.
http://en.wikipedia.org/wiki/Cartesian_coordinates
=============
I use Cartesian Coordinates for the SignPuddle data. We start with a
2dimensional canvas. Both the width and the height are divided into
specific points to create a grid. The center of the grid is point
(0,0). The horizontal position is called the X value. The vertical
position is called the Y value.
y



x  +x
+




+y
In my current design, the x and y values are unlimited. Negative to the
topleft. Positive to the bottomright.
In general, the challenge I face is to create a string that represents a
specific coordinate. My current string has the form "n100x100" for the
coordinate (100,100)". Simply replace the "" minus sign with an "n"
and replace the "," comma with an "x". The purpose of these
replacements is to enable double click selection. The "n" and the "x"
continue the string without a character that creates a gap.
Regular Expressions allow for efficient searching and pattern matching.
Regular expressions are simple and powerful when used correctly. They
can easily become overly complex and difficult to understand.
The current coordinate characters can be described with the regular
expression pattern:
"n?[09]+xn?[09]+"
This can be understood in parts.
n? , may or may not have an "n"
[09] , select one value between 0 and 9.
[09]+ , select one or more digits
x , match the character "x"
I've run into a problem that general searching is inefficient or slow.
This is due to Unicode and the current form of the coordinate value.
More accurate searching is forcing me use overly complex Regular
Expressions features, like negative lookahead.
I think I need to change the form of my coordinates so that searching is
efficient and accurate. I am considering a new form of coordinate
string that is a simple value 6 digits long.
The pattern can be described as "[09]{6}". Understood in parts as:
[09] , select one value between 0 and 9.
[09]{6} , select six values between 0 and 9.
I will limit both the X and Y axis to the values 500 to +499. The
center is still (0,0).
Here is the coordinate string for (0,0): "500500". The string is
divided in half. The first 3 digits are for the X value and the last 3
digits are used for the Y value. Simply subtract 500 from the value in
the string. To go in the reverse, simply add 500 to the value and
combine the Y and Y values. For example, the coordinate (111,111) would
have a string of "611611" and the coordinate (15,20) would have the
string "485480".
Depending on speed experiments, I may duplicate the SignPuddle XML files
with ASCII rather then the Preliminary Unicode. Large files have a lot
of wasted overhead processing UTF8 and Unicode values.
Thoughts? Opinions?
Steve
