[SQL] Which function transform x,y to latitude/longitude?

2007-04-25 Thread Nemo Terry

Hi,

For example x= 38356.62 y= 42365.19.how to transform it to latitude 1.399948, 
longitude 193.92644?

Which function I could use? I don’t know the algorithm.

Initial data is: ("+proj=cass +a=6378137.0 +rf=298.257223563 +lat_0=1.287639n 
+lon_0=103.8516e +x_0=3 +y_0=3").

Thanks a lot.

bill

_
与联机的朋友进行交流,请使用 Live Messenger; http://get.live.com/messenger/overview 



---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [SQL] Which function transform x,y to latitude/longitude?

2007-04-25 Thread Nemo Terry

I just know the correct data must be longitude 103.926669,latitude0.111827.
x,y from Cassini system.
Could you give me the source code how you calculate.Thanks a lot! 


From: Michael Fuhr <[EMAIL PROTECTED]>
To: Nemo Terry <[EMAIL PROTECTED]>
CC: pgsql-sql@postgresql.org
Subject: Re: [SQL] Which function transform x,y to latitude/longitude?
Date: Wed, 25 Apr 2007 08:16:56 -0600

On Wed, Apr 25, 2007 at 05:02:02PM +0800, Nemo Terry wrote:
> For example x= 38356.62 y= 42365.19.how to transform it to latitude
> 1.399948, longitude 193.92644?

Do you mean longitude 103.92644?  In what datum are the lat/lon
coordinates?  Where did you get the transformation in your example?

> Which function I could use? I don���t know the algorithm.
>
> Initial data is: ("+proj=cass +a=6378137.0 +rf=298.257223563
> +lat_0=1.287639n +lon_0=103.8516e +x_0=3 +y_0=3").

What's the source of these parameters?

You can perform transformations outside the database with PROJ.4
or inside the database with the PostGIS transform() function (which
uses PROJ.4).

http://proj.maptools.org/
http://postgis.refractions.net/

I don't see any exact matches in the PostGIS spatial_ref_sys table
for the parameters you posted you so if you use PostGIS then you
might have to insert a row to create your own spatial reference
system.  However, I did a few tests with your parameters and various
datums for the lat/lon and couldn't get the exact transformed values
in your example.

You might get more help on the PROJ.4 and PostGIS mailing lists.

--
Michael Fuhr

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


_
与世界各地的朋友进行交流,免费下载  Live Messenger; http://get.live.com/messenger/overview 



---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


[SQL] How to use function PointN?

2007-05-07 Thread Nemo Terry

select PointN(envelope(polyline),1) from highway;
return null,why?

_
享用世界上最大的电子邮件系统― MSN Hotmail。 http://www.hotmail.com 



---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


[SQL] How to process inverted comma in "EXECUTE 'insert into xxx values(...)';"?

2007-05-14 Thread Nemo Terry

Look at this problem:
when
execute 'insert into lse_installations values(' || ||obj_id|| || ',' || 
||div|| || ',' || ||sub|| || ',' || ||obj_type|| || ',' 
|| ||obj_name|| || ',' || ||pstcd|| || ',' || ||rdcd|| 
|| ',' || ||blkno|| || ',' || ||vldunt|| || ','|| cenlat || ',' 
|| cenlon || ')';
because obj_name from another table has value like this:S'pore High Polymer.
Following error raises:
ERROR: syntax error at or near "pore"

SQL state: 42601
Context: PL/pgSQL function "lse_installations" line 64 at execute statement

So how to process the single inverted comma in char variable?It makes me so 
desperate.

_
与世界各地的朋友进行交流,免费下载  Live Messenger; http://get.live.com/messenger/overview 



---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [SQL] How to process inverted comma in "EXECUTE 'insert into xxx values(...)

2007-05-14 Thread Nemo Terry

But I must use it in function,so...
Do you have another solution?



From: "Rodrigo De Le�n" <[EMAIL PROTECTED]>
To: pgsql-sql@postgresql.org
CC: "Nemo Terry" <[EMAIL PROTECTED]>
Subject: Re: [SQL] How to process inverted comma in "EXECUTE 'insert into xxx 
values(...)';"?
Date: Tue, 15 May 2007 01:25:25 -0500

On 5/14/07, Nemo Terry <[EMAIL PROTECTED]> wrote:

Look at this problem:
when
execute 'insert into lse_installations values(' || 
''''||obj_id||'''' || ',' || ''''||div||'''' || ',' || 
''''||sub||'''' || ',' || ''''||obj_type||'''' || ',' || 
''''||obj_name||'''' || ',' || ''''||pstcd||'''' || ',' || 
''''||rdcd||'''' || ',' || ''''||blkno||'''' || ',' || 
''''||vldunt||'''' || ','|| cenlat || ',' || cenlon || ')';
because obj_name from another table has value like this:S'pore High 
Polymer.

Following error raises:
ERROR: syntax error at or near "pore"
SQL state: 42601
Context: PL/pgSQL function "lse_installations" line 64 at execute 
statement


So how to process the single inverted comma in char variable?It 
makes me so desperate.


Why are you EXECUTEing the INSERT command? It's directly supported 
in

plpgsql, since it is a superset of SQL. That is, you can do:

INSERT INTO lse_installations
VALUES (obj_id, div, sub, obj_type, obj_name, pstcd, rdcd, 
blkno, vldunt

  , cenlat, cenlon);

Good luck.

---(end of 
broadcast)---

TIP 6: explain analyze is your friend


_
与联机的朋友进行交流,请使用  Live Messenger; http://get.live.com/messenger/overview 



---(end of broadcast)---
TIP 7: You can help support the PostgreSQL project by donating at

   http://www.postgresql.org/about/donate


Re: [SQL] How to process inverted comma in "EXECUTE 'insert into xxx values(...)

2007-05-15 Thread Nemo Terry

quote_literal() works.Thanks a lot!



From: Richard Huxton <[EMAIL PROTECTED]>
To: Nemo Terry <[EMAIL PROTECTED]>
CC: pgsql-sql@postgresql.org
Subject: Re: [SQL] How to process inverted comma in "EXECUTE 'insert into xxx 
values(...)
Date: Tue, 15 May 2007 08:12:55 +0100

Nemo Terry wrote:
> But I must use it in function,so...
> Do you have another solution?

>>> because obj_name from another table has value like this:S'pore High
>>> Polymer.
>>> Following error raises:
>>> ERROR: syntax error at or near "pore"

You'll want to look into the quote_ident() and quote_literal() functions
when constructing queries like this.

See functions and operators / string functions for details.

--
  Richard Huxton
  Archonet Ltd

---(end of broadcast)---
TIP 6: explain analyze is your friend


_
享用世界上最大的电子邮件系统― MSN Hotmail。 http://www.hotmail.com 



---(end of broadcast)---
TIP 7: You can help support the PostgreSQL project by donating at

   http://www.postgresql.org/about/donate