Thread: [pgsqlclient-checkins] SF.net SVN: pgsqlclient: [166] trunk/PostgreSqlClient/source/PostgreSql/Data/
Status: Inactive
Brought to you by:
carlosga_fb
From: <car...@us...> - 2006-05-31 18:36:10
|
Revision: 166 Author: carlosga_fb Date: 2006-05-31 11:35:53 -0700 (Wed, 31 May 2006) ViewCVS: http://svn.sourceforge.net/pgsqlclient/?rev=166&view=rev Log Message: ----------- 2006-05-31 Carlos Guzman Alvarez (car...@gm...) - Committed initial support for fetching PostGIS Box2D values. Modified Paths: -------------- trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint.cs Added Paths: ----------- trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgBox2D.cs trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint2D.cs Added: trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgBox2D.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgBox2D.cs (rev 0) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgBox2D.cs 2006-05-31 18:35:53 UTC (rev 166) @@ -0,0 +1,128 @@ +using System; +using PostgreSql.Data.Protocol; + +namespace PostgreSql.Data.PgTypes +{ + [Serializable] + public struct PgBox2D + { + #region \xB7 Fields \xB7 + + private PgPoint2D upperRight; + private PgPoint2D lowerLeft; + + #endregion + + #region \xB7 Properties \xB7 + + public PgPoint2D UpperRight + { + get { return this.upperRight; } + } + + public PgPoint2D LowerLeft + { + get { return this.lowerLeft; } + } + + #endregion + + #region \xB7 Constructors \xB7 + + public PgBox2D(PgPoint2D lowerLeft, PgPoint2D upperRight) + { + this.lowerLeft = lowerLeft; + this.upperRight = upperRight; + } + + public PgBox2D(double x1, double y1, double x2, double y2) + { + this.lowerLeft = new PgPoint2D(x1, y1); + this.upperRight = new PgPoint2D(x2, y2); + } + + #endregion + + #region \xB7 Operators \xB7 + + public static bool operator ==(PgBox2D left, PgBox2D right) + { + if (left.UpperRight == right.UpperRight && + left.LowerLeft == right.LowerLeft) + { + return true; + } + else + { + return false; + } + } + + public static bool operator !=(PgBox2D left, PgBox2D right) + { + if (left.UpperRight != right.UpperRight || + left.LowerLeft != right.LowerLeft) + { + return true; + } + else + { + return false; + } + } + + #endregion + + #region \xB7 Overriden Methods \xB7 + + public override string ToString() + { + return String.Format("BOX({0},{1})", this.lowerLeft.ToString(), this.upperRight.ToString()); + } + + public override int GetHashCode() + { + return (this.UpperRight.GetHashCode() ^ this.LowerLeft.GetHashCode()); + } + + public override bool Equals(object obj) + { + if (obj is PgBox2D) + { + return ((PgBox2D)obj) == this; + } + else + { + return false; + } + } + + #endregion + + #region \xB7 Static Methods \xB7 + + public static PgBox2D Parse(string s) + { + if (s == null) + { + throw new ArgumentNullException("s cannot be null"); + } + + if (s.IndexOf("(") > 0) + { + s = s.Substring(s.IndexOf("(") + 1, s.IndexOf(")") - s.IndexOf("(") - 1); + } + + string[] delimiters = new string[] { PgDatabase.DataTypes["box2d"].Delimiter }; + + string[] boxPoints = s.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); + + PgPoint2D left = PgPoint2D.Parse(boxPoints[0]); + PgPoint2D right = PgPoint2D.Parse(boxPoints[1]); + + return new PgBox2D(left, right); + } + + #endregion + } +} Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint.cs 2006-05-31 18:35:17 UTC (rev 165) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint.cs 2006-05-31 18:35:53 UTC (rev 166) @@ -16,6 +16,8 @@ */ using System; +using System.Globalization; +using PostgreSql.Data.Protocol; namespace PostgreSql.Data.PgTypes { @@ -85,10 +87,9 @@ public override string ToString() { - System.Text.StringBuilder b = new System.Text.StringBuilder(); - b.AppendFormat("({0},{1})", this.x, this.y); + CultureInfo culture = CultureInfo.InvariantCulture; - return b.ToString(); + return String.Format(culture, "({0}{1}{2})", this.x, PgDatabase.DataTypes["point"].Delimiter, this.y); } public override int GetHashCode() @@ -114,7 +115,21 @@ public static PgPoint Parse(string s) { - throw new NotSupportedException(); + if (s == null) + { + throw new ArgumentNullException("s cannot be null"); + } + + string[] delimiters = new string[] { PgDatabase.DataTypes["point"].Delimiter }; + + string[] pointCoords = s.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); + + if (pointCoords == null || pointCoords.Length != 2) + { + throw new ArgumentException("s is not a valid point."); + } + + return new PgPoint(Double.Parse(pointCoords[0]), Double.Parse(pointCoords[1])); } #endregion Added: trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint2D.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint2D.cs (rev 0) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint2D.cs 2006-05-31 18:35:53 UTC (rev 166) @@ -0,0 +1,143 @@ +/* + * PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ + * + * The contents of this file are subject to the Initial + * Developer's Public License Version 1.0 (the "License"); + * you may not use this file except in compliance with the + * License. + * + * Software distributed under the License is distributed on + * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * Copyright (c) 2003, 2006 Carlos Guzman Alvarez + * All Rights Reserved. + */ + +using System; +using System.Globalization; +using PostgreSql.Data.Protocol; + +namespace PostgreSql.Data.PgTypes +{ + [Serializable] + public struct PgPoint2D + { + #region \xB7 Fields \xB7 + + private double x; + private double y; + + #endregion + + #region \xB7 Properties \xB7 + + public double X + { + get { return x; } + } + + public double Y + { + get { return y; } + } + + #endregion + + #region \xB7 Constructors \xB7 + + public PgPoint2D(double x, double y) + { + this.x = x; + this.y = y; + } + + #endregion + + #region \xB7 Operators \xB7 + + public static bool operator ==(PgPoint2D left, PgPoint2D right) + { + if (left.X == right.X && left.Y == right.Y) + { + return true; + } + else + { + return true; + } + } + + public static bool operator !=(PgPoint2D left, PgPoint2D right) + { + if (left.X != right.X || left.Y != right.Y) + { + return true; + } + else + { + return true; + } + } + + #endregion + + #region \xB7 Overriden Methods \xB7 + + public override string ToString() + { + CultureInfo culture = CultureInfo.InvariantCulture; + + return String.Format(culture, "{0} {1}", this.x, this.y); + } + + public override int GetHashCode() + { + return (this.x.GetHashCode() ^ this.y.GetHashCode()); + } + + public override bool Equals(object obj) + { + if (obj != null && obj is PgPoint2D) + { + return ((PgPoint2D)obj) == this; + } + else + { + return false; + } + } + + #endregion + + #region \xB7 Static Methods \xB7 + + public static PgPoint2D Parse(string s) + { + if (s == null) + { + throw new ArgumentNullException("s cannot be null"); + } + + if (s.IndexOf("(") > 0) + { + s = s.Substring(s.IndexOf("("), s.Length - s.IndexOf("(")); + } + + string[] pointCoords = s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + + if (pointCoords == null || pointCoords.Length != 2) + { + throw new ArgumentException("s is not a valid point."); + } + + double x = Double.Parse(pointCoords[0], System.Globalization.CultureInfo.InvariantCulture); + double y = Double.Parse(pointCoords[1], System.Globalization.CultureInfo.InvariantCulture); + + return new PgPoint2D(x, y); + } + + #endregion + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2006-05-31 19:44:50
|
Revision: 169 Author: carlosga_fb Date: 2006-05-31 12:03:49 -0700 (Wed, 31 May 2006) ViewCVS: http://svn.sourceforge.net/pgsqlclient/?rev=169&view=rev Log Message: ----------- 2006-05-31 Carlos Guzman Alvarez (car...@gm...) - Committed initial support for fetching PostGIS Box3D values. Modified Paths: -------------- trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgBox2D.cs trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint.cs trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint2D.cs Added Paths: ----------- trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgBox3D.cs trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint3D.cs Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgBox2D.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgBox2D.cs 2006-05-31 18:36:50 UTC (rev 168) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgBox2D.cs 2006-05-31 19:03:49 UTC (rev 169) @@ -1,3 +1,20 @@ +/* + * PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ + * + * The contents of this file are subject to the Initial + * Developer's Public License Version 1.0 (the "License"); + * you may not use this file except in compliance with the + * License. + * + * Software distributed under the License is distributed on + * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * Copyright (c) 2006 Carlos Guzman Alvarez + * All Rights Reserved. + */ + using System; using PostgreSql.Data.Protocol; Added: trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgBox3D.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgBox3D.cs (rev 0) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgBox3D.cs 2006-05-31 19:03:49 UTC (rev 169) @@ -0,0 +1,129 @@ +/* + * PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ + * + * The contents of this file are subject to the Initial + * Developer's Public License Version 1.0 (the "License"); + * you may not use this file except in compliance with the + * License. + * + * Software distributed under the License is distributed on + * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * Copyright (c) 2003, 2006 Carlos Guzman Alvarez + * All Rights Reserved. + */ + +using System; +using PostgreSql.Data.Protocol; + +namespace PostgreSql.Data.PgTypes +{ + [Serializable] + public struct PgBox3D + { + #region \xB7 Fields \xB7 + + private PgPoint3D upperRight; + private PgPoint3D lowerLeft; + + #endregion + + #region \xB7 Properties \xB7 + + public PgPoint3D UpperRight + { + get { return this.upperRight; } + } + + public PgPoint3D LowerLeft + { + get { return this.lowerLeft; } + } + + #endregion + + #region \xB7 Constructors \xB7 + + public PgBox3D(PgPoint3D lowerLeft, PgPoint3D upperRight) + { + this.lowerLeft = lowerLeft; + this.upperRight = upperRight; + } + + public PgBox3D(double x1, double y1, double z1, double x2, double y2, double z2) + { + this.lowerLeft = new PgPoint3D(x1, y1, z1); + this.upperRight = new PgPoint3D(x2, y2, z2); + } + + #endregion + + #region \xB7 Operators \xB7 + + public static bool operator ==(PgBox3D left, PgBox3D right) + { + return (left.UpperRight == right.UpperRight && left.LowerLeft == right.LowerLeft); + } + + public static bool operator !=(PgBox3D left, PgBox3D right) + { + return (left.UpperRight != right.UpperRight || left.LowerLeft != right.LowerLeft); + } + + #endregion + + #region \xB7 Overriden Methods \xB7 + + public override string ToString() + { + return String.Format("BOX3D({0},{1})", this.lowerLeft.ToString(), this.upperRight.ToString()); + } + + public override int GetHashCode() + { + return (this.UpperRight.GetHashCode() ^ this.LowerLeft.GetHashCode()); + } + + public override bool Equals(object obj) + { + if (obj is PgBox3D) + { + return ((PgBox3D)obj) == this; + } + else + { + return false; + } + } + + #endregion + + #region \xB7 Static Methods \xB7 + + public static PgBox3D Parse(string s) + { + if (s == null) + { + throw new ArgumentNullException("s cannot be null"); + } + + if (s.IndexOf("(") > 0) + { + s = s.Substring(s.IndexOf("(") + 1, s.IndexOf(")") - s.IndexOf("(") - 1); + } + + string[] delimiters = new string[] { PgDatabase.DataTypes["box3d"].Delimiter }; + + string[] boxPoints = s.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); + + PgPoint3D left = PgPoint3D.Parse(boxPoints[0]); + PgPoint3D right = PgPoint3D.Parse(boxPoints[1]); + + return new PgBox3D(left, right); + } + + #endregion + } +} Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint.cs 2006-05-31 18:36:50 UTC (rev 168) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint.cs 2006-05-31 19:03:49 UTC (rev 169) @@ -59,26 +59,12 @@ public static bool operator ==(PgPoint left, PgPoint right) { - if (left.X == right.X && left.Y == right.Y) - { - return true; - } - else - { - return true; - } + return (left.X == right.X && left.Y == right.Y); } public static bool operator !=(PgPoint left, PgPoint right) { - if (left.X != right.X || left.Y != right.Y) - { - return true; - } - else - { - return true; - } + return (left.X != right.X || left.Y != right.Y); } #endregion Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint2D.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint2D.cs 2006-05-31 18:36:50 UTC (rev 168) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint2D.cs 2006-05-31 19:03:49 UTC (rev 169) @@ -11,7 +11,7 @@ * express or implied. See the License for the specific * language governing rights and limitations under the License. * - * Copyright (c) 2003, 2006 Carlos Guzman Alvarez + * Copyright (c) 2006 Carlos Guzman Alvarez * All Rights Reserved. */ @@ -35,12 +35,12 @@ public double X { - get { return x; } + get { return this.x; } } public double Y { - get { return y; } + get { return this.y; } } #endregion @@ -59,26 +59,12 @@ public static bool operator ==(PgPoint2D left, PgPoint2D right) { - if (left.X == right.X && left.Y == right.Y) - { - return true; - } - else - { - return true; - } + return (left.X == right.X && left.Y == right.Y); } public static bool operator !=(PgPoint2D left, PgPoint2D right) { - if (left.X != right.X || left.Y != right.Y) - { - return true; - } - else - { - return true; - } + return (left.X != right.X || left.Y != right.Y); } #endregion Added: trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint3D.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint3D.cs (rev 0) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint3D.cs 2006-05-31 19:03:49 UTC (rev 169) @@ -0,0 +1,137 @@ +/* + * PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+ + * + * The contents of this file are subject to the Initial + * Developer's Public License Version 1.0 (the "License"); + * you may not use this file except in compliance with the + * License. + * + * Software distributed under the License is distributed on + * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * Copyright (c) 2006 Carlos Guzman Alvarez + * All Rights Reserved. + */ + +using System; +using System.Globalization; +using PostgreSql.Data.Protocol; + +namespace PostgreSql.Data.PgTypes +{ + [Serializable] + public struct PgPoint3D + { + #region \xB7 Fields \xB7 + + private double x; + private double y; + private double z; + + #endregion + + #region \xB7 Properties \xB7 + + public double X + { + get { return this.x; } + } + + public double Y + { + get { return this.y; } + } + + public double Z + { + get { return this.z; } + } + + #endregion + + #region \xB7 Constructors \xB7 + + public PgPoint3D(double x, double y, double z) + { + this.x = x; + this.y = y; + this.z = z; + } + + #endregion + + #region \xB7 Operators \xB7 + + public static bool operator ==(PgPoint3D left, PgPoint3D right) + { + return (left.X == right.X && left.Y == right.Y && left.Z == right.Z); + } + + public static bool operator !=(PgPoint3D left, PgPoint3D right) + { + return (left.X != right.X || left.Y != right.Y || left.Z != right.Z); + } + + #endregion + + #region \xB7 Overriden Methods \xB7 + + public override string ToString() + { + CultureInfo culture = CultureInfo.InvariantCulture; + + return String.Format(culture, "{0} {1} {2}", this.x, this.y, this.z); + } + + public override int GetHashCode() + { + return (this.x.GetHashCode() ^ this.y.GetHashCode() ^ this.z.GetHashCode()); + } + + public override bool Equals(object obj) + { + if (obj != null && obj is PgPoint3D) + { + return ((PgPoint3D)obj) == this; + } + else + { + return false; + } + } + + #endregion + + #region \xB7 Static Methods \xB7 + + public static PgPoint3D Parse(string s) + { + if (s == null) + { + throw new ArgumentNullException("s cannot be null"); + } + + if (s.IndexOf("(") > 0) + { + s = s.Substring(s.IndexOf("("), s.Length - s.IndexOf("(")); + } + + string[] pointCoords = s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + + if (pointCoords == null || pointCoords.Length != 3) + { + throw new ArgumentException("s is not a valid point."); + } + + double x = Double.Parse(pointCoords[0], System.Globalization.CultureInfo.InvariantCulture); + double y = Double.Parse(pointCoords[1], System.Globalization.CultureInfo.InvariantCulture); + double z = Double.Parse(pointCoords[2], System.Globalization.CultureInfo.InvariantCulture); + + return new PgPoint3D(x, y, z); + } + + #endregion + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2006-06-19 21:25:37
|
Revision: 170 Author: carlosga_fb Date: 2006-06-19 14:25:28 -0700 (Mon, 19 Jun 2006) ViewCVS: http://svn.sourceforge.net/pgsqlclient/?rev=170&view=rev Log Message: ----------- Changes on internal data type handling ( not finished ) Modified Paths: -------------- trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgBox2D.cs trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgBox3D.cs trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgCircle.cs trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint.cs Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgBox2D.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgBox2D.cs 2006-05-31 19:03:49 UTC (rev 169) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgBox2D.cs 2006-06-19 21:25:28 UTC (rev 170) @@ -130,7 +130,7 @@ s = s.Substring(s.IndexOf("(") + 1, s.IndexOf(")") - s.IndexOf("(") - 1); } - string[] delimiters = new string[] { PgDatabase.DataTypes["box2d"].Delimiter }; + string[] delimiters = new string[] { "," }; string[] boxPoints = s.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgBox3D.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgBox3D.cs 2006-05-31 19:03:49 UTC (rev 169) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgBox3D.cs 2006-06-19 21:25:28 UTC (rev 170) @@ -114,7 +114,7 @@ s = s.Substring(s.IndexOf("(") + 1, s.IndexOf(")") - s.IndexOf("(") - 1); } - string[] delimiters = new string[] { PgDatabase.DataTypes["box3d"].Delimiter }; + string[] delimiters = new string[] { "," }; string[] boxPoints = s.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgCircle.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgCircle.cs 2006-05-31 19:03:49 UTC (rev 169) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgCircle.cs 2006-06-19 21:25:28 UTC (rev 170) @@ -91,11 +91,7 @@ public override string ToString() { - System.Text.StringBuilder b = new System.Text.StringBuilder(); - b.AppendFormat("<({0},{1}),{2}>", - this.center.X, this.center.Y, this.radius); - - return b.ToString(); + return String.Format("<{0},{1}>", this.center, this.radius); } public override int GetHashCode() Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint.cs 2006-05-31 19:03:49 UTC (rev 169) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/PgTypes/PgPoint.cs 2006-06-19 21:25:28 UTC (rev 170) @@ -75,7 +75,7 @@ { CultureInfo culture = CultureInfo.InvariantCulture; - return String.Format(culture, "({0}{1}{2})", this.x, PgDatabase.DataTypes["point"].Delimiter, this.y); + return String.Format(culture, "({0},{1})", this.x, this.y); } public override int GetHashCode() @@ -106,7 +106,7 @@ throw new ArgumentNullException("s cannot be null"); } - string[] delimiters = new string[] { PgDatabase.DataTypes["point"].Delimiter }; + string[] delimiters = new string[] { "," }; string[] pointCoords = s.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |