dbTalk Databases Forums  

Point Data formatting problem

comp.databases.postgresql comp.databases.postgresql


Discuss Point Data formatting problem in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Joe Stateson
 
Posts: n/a

Default Point Data formatting problem - 11-07-2007 , 03:26 PM






We are using PostgreSQL "point data" for a coordinate system (ie: latitude
longitude). Browsing a location table using phpPgAdmin shows for example

(29.451972,-98.748106) this is what we want.

My web app uses a Microsoft GridView and the corresponding point shows up
in the grid column as

(29.451972000000001,-98.748106000000007)

I cannot seem to round the values down and have been guessing at the format
specifier after reading this:
http://msdn2.microsoft.com/en-us/net.../aa569608.aspx

"{0:{{0.000000}}}"
had no effect: it was no different than if it was not coded up.

"{0:{{0.000000}}} {1:{{0.000000}}}"
gave an error that two values were expected but only one supplied.


I tried various combinations before giving up. I do not know how to format
the output (using the built in item format) so that the grid shows a pair of
values to only 6 places each. It seems I will have to format my own output
string and substitute it at RowDataBound time. The above format strings
work OK for fields with just single floats.


--
================================================== ====================
Joseph "Beemer Biker" Stateson
http://ResearchRiders.org Ask about my 99'R1100RT
================================================== ====================








Reply With Quote
  #2  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: Point Data formatting problem - 11-08-2007 , 03:42 AM






In comp.databases.postgresql Joe Stateson <jstateson (AT) swri (DOT) edu> wrote:
Quote:
My web app uses a Microsoft GridView and the corresponding point shows up
in the grid column as

(29.451972000000001,-98.748106000000007)

I cannot seem to round the values down and have been guessing at the
format specifier after reading this:
http://msdn2.microsoft.com/en-us/net.../aa569608.aspx

[...]

I tried various combinations before giving up.
No PostgreSQL content - why did you crosspost here?

Yours,
Laurenz Albe


Reply With Quote
  #3  
Old   
Joe Stateson
 
Posts: n/a

Default Re: Point Data formatting problem - 11-08-2007 , 09:35 AM



X-NETCOP-DISCLAIMER: This was not cross-posted.

"Laurenz Albe" <invite (AT) spam (DOT) to.invalid> wrote

Quote:
In comp.databases.postgresql Joe Stateson <jstateson (AT) swri (DOT) edu> wrote:
My web app uses a Microsoft GridView and the corresponding point shows
up
in the grid column as

(29.451972000000001,-98.748106000000007)

I cannot seem to round the values down and have been guessing at the
format specifier after reading this:
http://msdn2.microsoft.com/en-us/net.../aa569608.aspx

[...]

I tried various combinations before giving up.

No PostgreSQL content - why did you crosspost here?
The main problem seems to be the "Point Data" that is part of the geometric
data types that PostgreSQL supports. I have not used this "point type" in a
database before. I could be mistaken, but this seem unique to PostgreSQL.
We normally use Lat's and Long's in separate fields of a table and use ESRI
MapObjects or ArcObjects to determine if a location lies within a search
ellipse. Those are expensive products and PostgreSQL seems to have some of
these features built in. Unfortunately, the "free gridview" that comes with
Microsoft VS8 for asp.net does not seem capable of displaying point type
data where one can easily control the output format.

I appreciate you responding to my question. Many of the responses I get on
the microsoft.public forums are to get microsoft sql server.

Possibly, double precision data is being supplied instead of single
precision and there might be some way to specify only single precision
floats. I am just guessing. However, I remember haveing a problem with a
Visual Basic program that made a call across a com interface and the "C"
code cleared a bit in the x86 register that determined how rounding was done
when the 80 bits of the x86 was converted back to 53 bits. This caused a
very similar rounding problem but was easily fixed in the C code. Possibly
something like that is happening in the odbc driver I got from postgresq.org
but that is just a guess and it is more likely that microsoft has no
interest in supporting "point data" in their C# asp grid.


======================================
Joseph "Beemer Biker" Stateson
http://TipsForTheComputingImpaired.com
http://ResearchRiders.org Ask about my 99'R1100RT
=======================================



Reply With Quote
  #4  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: Point Data formatting problem - 11-09-2007 , 04:44 AM



Joe Stateson <jstateson (AT) swri (DOT) edu> wrote:
Quote:
My web app uses a Microsoft GridView and the corresponding point shows
up
in the grid column as

(29.451972000000001,-98.748106000000007)

I cannot seem to round the values down and have been guessing at the
format specifier after reading this:
http://msdn2.microsoft.com/en-us/net.../aa569608.aspx

[...]

I tried various combinations before giving up.

No PostgreSQL content - why did you crosspost here?

The main problem seems to be the "Point Data" that is part of the
geometric data types that PostgreSQL supports. I have not used this
"point type" in a database before. I could be mistaken, but this seem
unique to PostgreSQL.
I didn't mean to offend - I had the impression that your question was
about formatting output in a Microsoft program.

In PostgreSQL, you can round numbers with the function round(numeric, int).
You can access the coordinates of a point as if it were an array with
two elements.

So to get the x coordinate of point p rounded to 2 decimal places, you
could use

round(p[0]::numeric, 2)

Does that help?

Yours,
Laurenz Albe


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.