Murat,<br><br>Put aside linestrings and geometries. First you need to have a wkt representation of your line segment. Your MySQL query is returning a number. That should be an indicator that your query was wrong. You were using the wrong operator. You need to convert the latitude and longitude values to string and concatenate the them with the other strings to make up the wkt of linestring geometries. Otherwise, MySQL is just adding the string and decimal values mathematically.<br>
<br>Use the CONVERT function as described in the website: <a href="http://www.geeksengine.com/database/single-row-functions/conversion-functions.php">http://www.geeksengine.com/database/single-row-functions/conversion-functions.php</a><br>
<br><div class="gmail_quote">On Fri, Mar 2, 2012 at 5:38 PM, Murat Beyhan <span dir="ltr"><<a href="mailto:beyhan@deprem.gov.tr">beyhan@deprem.gov.tr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Chaitanya,<br>
<br>
I could not do this using sql sorry.<br>
<br>
But I have an another idea is it good way to store these data as a<br>
spatial database in MySql.<br>
I try this but when I insert data to mysql table<br>
I have problem .<br>
I have created a table<br>
as follows<br>
<br>
eq_id varchar(14)<br>
fault linestring<br>
<br>
then I will insert data (if I success how to do that)<br>
then I will use this table from mapserver.<br>
is this proper way.<br>
Or how to declare geom column as string at sql statement as follows<br>
<div class="im"><br>
create view lineview as select eq_id, "LINESTRING(" + lon1 + " " + lat1<br>
+ "," + lon2 + " " + lat2 + ")" as geom from sfault<br>
<br>
<br>
</div>please give your idea...<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On Thu, 2012-03-01 at 14:40 +0530, Chaitanya kumar CH wrote:<br>
> Murat,<br>
><br>
><br>
> It's not working. the geom field should not be 'Real'. It should be<br>
> 'String'. Try something else other than the '+' operator in the SQL<br>
> syntax to create the geom field in the view.<br>
><br>
> On Thu, Mar 1, 2012 at 12:48 PM, Murat Beyhan <<a href="mailto:beyhan@deprem.gov.tr">beyhan@deprem.gov.tr</a>><br>
> wrote:<br>
> Chaitanya,<br>
><br>
> I have had a progress about VRT data access<br>
> but I afraid something wrong in mapserver .map file.<br>
><br>
> here is the test.vrt file and I use in map file with<br>
> connection ogr<br>
> functionality. :<br>
><br>
> <OGRVRTDataSource><br>
> <OGRVRTLayer name="dynamic"><br>
> <SrcDataSource>MYSQL:dynamic,user=root,password=mysql_passwd,host=localhost,port=3306,tables=lineview</SrcDataSource><br>
> <SrcSql>select eq_id, geom from lineview</SrcSql><br>
> <GeometryType>wkbLineString</GeometryType><br>
> <GeometryField encoding="WKT" field="geom"/><br>
><br>
> </OGRVRTLayer><br>
> </OGRVRTDataSource><br>
><br>
> then the command<br>
><br>
><br>
> [murat@localhost stations]$ ogrinfo -ro -al test.vrt<br>
> INFO: Open of `test.vrt'<br>
> using driver `VRT' successful.<br>
><br>
><br>
> Layer name: dynamic<br>
> Geometry: Line String<br>
> Feature Count: 2<br>
> Layer SRS WKT:<br>
> (unknown)<br>
><br>
> eq_id: String (42.0)<br>
> geom: Real (23.0)<br>
> OGRFeature(dynamic):0<br>
> eq_id (String) = 20111023101120<br>
> geom (Real) = 164<br>
><br>
> OGRFeature(dynamic):1<br>
> eq_id (String) = 20100308023229<br>
> geom (Real) = 163<br>
><br>
><br>
><br>
> it works now but mapserver gives an error as follows:<br>
><br>
> Server error!<br>
> The server encountered an internal error and was unable to<br>
> complete your<br>
> request.<br>
><br>
> Error message:<br>
> Premature end of script headers: mapserv<br>
><br>
> If you think this is a server error, please contact the<br>
> webmaster.<br>
><br>
><br>
> Error 500<br>
> 10.14.0.67<br>
> Apache/2.2.14 (Mandriva Linux/PREFORK-1.6mdv2010.0)<br>
><br>
><br>
><br>
> I think I will solve it with your help.<br>
><br>
> Many thanks<br>
><br>
> Murat<br>
><br>
><br>
> On Thu, 2012-03-01 at 09:22 +0530, Chaitanya kumar CH wrote:<br>
> > Murat,<br>
> ><br>
> > You should check MySQL's SQL syntax to concatenate strings<br>
> and<br>
> > decimals to produce a string.<br>
> ><br>
> > On Wednesday, February 29, 2012, Murat Beyhan<br>
> <<a href="mailto:beyhan@deprem.gov.tr">beyhan@deprem.gov.tr</a>><br>
> > wrote:<br>
> > > Chaitanya,<br>
> > ><br>
> > > here is the structure of table on database<br>
> > ><br>
> > > sfault :<br>
> > ><br>
> > > eq_id varchar(14)<br>
> > > lat1 decimal(7,4)<br>
> > > lon1 decimal(7,4)<br>
> > > lat2 decimal(7,4)<br>
> > > lon2 decimal(7,4)<br>
> > ><br>
> > > lineview :<br>
> > ><br>
> > ><br>
> > > eq_id varchar(14)<br>
> > > geom double<br>
> > ><br>
> > ><br>
> > > it seams geom as double<br>
> > > I thing it should be geometry isn't it?<br>
> > ><br>
> > > may be I have to change structure of lineview by changing<br>
> following<br>
> > > Roberts' suggestion to create view on database<br>
> > ><br>
> > > create view lineview as select eq_id, "LINESTRING(" +<br>
> lon1 + " " +<br>
> > lat1<br>
> > > + "," + lon2 + " " + lat2 + ")" as geom from sfault<br>
> > ><br>
> > ><br>
> > > but I'm not sure for the line.<br>
> > ><br>
> > > VTR for points, I have tested and works well<br>
> > ><br>
> > ><br>
> > > but for line still could not achieved yet, please give me<br>
> another<br>
> > idea.<br>
> > ><br>
> > > here is test.vrt file<br>
> > ><br>
> > > <OGRVRTDataSource><br>
> > > <OGRVRTLayer name="sta"><br>
> > ><br>
> ><br>
> <SrcDataSource>MYSQL:stations,user=root,password=mysql_passwd,host=localhost,port=3306,tables=sta</SrcDataSource><br>
> > > <SrcSQL>SELECT sta_id as name,type,latitude,longitude from<br>
> sta where<br>
> > > type like "%SMACH%"</SrcSQL><br>
> > > <GeometryType>wkbPoint</GeometryType><br>
> > > <GeometryField encoding="PointFromColumns" x="longitude"<br>
> > y="latitude"/><br>
> > > </OGRVRTLayer><br>
> > > </OGRVRTDataSource><br>
> > ><br>
> > > and following code gives successful result as you see<br>
> > ><br>
> > ><br>
> > > ogrinfo -ro -al test.vrt<br>
> > ><br>
> > > INFO: Open of `test.vrt' using driver `VRT' successful.<br>
> > ><br>
> > > Layer name: sta<br>
> > > Geometry: Point<br>
> > > Feature Count: 12<br>
> > > Layer SRS WKT:<br>
> > > (unknown)<br>
> > > name: String (12.0)<br>
> > > type: String (24.0)<br>
> > > latitude: Real (5.4)<br>
> > > longitude: Real (5.4)<br>
> > > OGRFeature(sta):0<br>
> > > name (String) = 0617<br>
> > > type (String) = SMACH<br>
> > > latitude (Real) = 40.4569<br>
> > > longitude (Real) = 32.6319<br>
> > > POINT (32.631900000000002 40.456899999999997)<br>
> > ><br>
> > > OGRFeature(sta):1<br>
> > > name (String) = 0618<br>
> > > type (String) = SMACH<br>
> > > latitude (Real) = 40.4798<br>
> > > longitude (Real) = 32.4555<br>
> > > POINT (32.4555 40.479799999999997)<br>
> > ><br>
> > > .<br>
> > > .<br>
> > > .<br>
> > > .<br>
> > ><br>
> > ><br>
> > > As you see this works well.<br>
> > ><br>
> > > I hope you can catch point what is wrong or lack of on my<br>
> works....<br>
> > ><br>
> > ><br>
> > > Thanks again<br>
> > ><br>
> > ><br>
> > ><br>
> > ><br>
> > > On Tue, 2012-02-28 at 18:08 +0530, Chaitanya kumar CH<br>
> wrote:<br>
> > >> Murat,<br>
> > >><br>
> > >><br>
> > >> I see that your view, lineview, doesn't give the<br>
> expected geometry<br>
> > >> type with ogrinfo. It is showing the datatype as Real.<br>
> Check if the<br>
> > >> datatype of geom is actually string/text.<br>
> > >><br>
> > >> On Tue, Feb 28, 2012 at 12:49 PM, Murat Beyhan<br>
> > <<a href="mailto:beyhan@deprem.gov.tr">beyhan@deprem.gov.tr</a>><br>
> > >> wrote:<br>
> > >> Chaitanya,<br>
> > >><br>
> > >><br>
> > >> Map file which is try to draw line as follows<br>
> > >> are there any problem on the code<br>
> > >><br>
> > >> LAYER<br>
> > >> NAME sfault1<br>
> > >> CONNECTIONTYPE OGR<br>
> > >> CONNECTION '<OGRVRTDataSource><br>
> > >> <OGRVRTLayer name="lineview"><br>
> > >><br>
> > >><br>
> ><br>
> <SrcDataSource>MYSQL:dynamic,user=root,password=mysqlpasswd,host=localhost,port=3306,tables=lineview</SrcDataSource><br>
> > >> <SrcLayer>lineview</SrcLayer><br>
> > >> <GeometryType>wkbLineString</GeometryType><br>
> > >> <GeometryField encoding="WKT" field="geom"/><br>
> > >> <LayerSRS>WGS84</LayerSRS><br>
> > >> <FID>eq_id</FID><br>
> > >> </OGRVRTLayer><br>
> > >> </OGRVRTDataSource>'<br>
> > >> DATA sfault1<br>
> > >> STATUS on<br>
> > >> TYPE line<br>
> > >> CLASS<br>
> > >> NAME "Source Fault"<br>
> > >> SYMBOL "cline"<br>
> > >> SIZE 3<br>
> > >> COLOR 0 0 255<br>
> > >> END<br>
> > >> END<br>
> > >><br>
> > >><br>
> > >> ogrinfo<br>
> > >><br>
> ><br>
> MYSQL:dynamic,user=root,password=mysqlpasswd,host=localhost,port=3306<br>
> > >> sfault -summary<br>
> > >> INFO: Open of<br>
> > >><br>
> ><br>
> `MYSQL:dynamic,user=root,password=mysqlpasswd,host=localhost,port=3306'<br>
> > >> using driver `MySQL' successful.<br>
> > >><br>
> > >> Layer name: sfault<br>
> > >> Geometry: None<br>
> > >> Feature Count: 1<br>
> > >> Layer SRS WKT:<br>
> > >> (unknown)<br>
> > >> eq_id: String (14.0)<br>
> > >> lat1: Real (7.4)<br>
> > >> lon1: Real (7.4)<br>
> > >> lat2: Real (7.4)<br>
> > >> lon2: Real (7.4)<br>
> > >><br>
> > >> **************linewiew created by following sql<br>
> > >> statement:*************<br>
> > >><br>
> > >><br>
> > >> create view lineview as select eq_id,<br>
> "LINESTRING(" + lon1<br>
> > +<br>
> > >> " " + lat1<br>
> > >> + "," + lon2 + " " + lat2 + ")" as geom from<br>
> sfault<br>
> > >><br>
> > >><br>
> > >> then<br>
> > >><br>
> > >> [murat@localhost ~]$ ogrinfo<br>
> > >><br>
> ><br>
> MYSQL:dynamic,user=root,password=mysqlpasswd,host=localhost,port=3306<br>
> > >> lineview -summary<br>
> > >> INFO: Open of<br>
> > >><br>
> ><br>
> `MYSQL:dynamic,user=root,password=mysqlpasswd,host=localhost,port=3306'<br>
> > >> using driver `MySQL' successful.<br>
> > >><br>
> > >> Layer name: lineview<br>
> > >> Geometry: None<br>
> > >> Feature Count: 1<br>
> > >> Layer SRS WKT:<br>
> > >> (unknown)<br>
> > >> eq_id: String (14.0)<br>
> > >> geom: Real (0.0)<br>
> > >><br>
> > >><br>
> > >><br>
> ><br>
> > --<br>
> > Best regards,<br>
> > Chaitanya kumar CH.<br>
> ><br>
> > <a href="tel:%2B91-9494447584" value="+919494447584">+91-9494447584</a><br>
> > 17.2416N 80.1426E<br>
> ><br>
><br>
> > --<br>
> > This message has been scanned for viruses and<br>
> > dangerous content by MailScanner, and is<br>
> > believed to be clean.<br>
><br>
><br>
><br>
> Murat BEYHAN<br>
><br>
> Jeofizik Y.Müh.<br>
> T.C. Başbakanlık<br>
> Afet ve Acil Durum Yönetimi Başkanlığı<br>
> Deprem Dairesi Başkanlığı<br>
> Eskişehir Yolu 12. Km.<br>
> Lodumlu/ANKARA<br>
> Tel: 312 2872680-1556<br>
> <a href="mailto:email%3Abeyhan@deprem.gov.tr">email:beyhan@deprem.gov.tr</a><br>
><br>
><br>
><br>
><br>
> --<br>
> This message has been scanned for viruses and<br>
> dangerous content by MailScanner, and is<br>
> believed to be clean.<br>
><br>
><br>
><br>
><br>
><br>
><br>
> --<br>
> Best regards,<br>
> Chaitanya kumar CH.<br>
><br>
> <a href="tel:%2B91-9494447584" value="+919494447584">+91-9494447584</a><br>
> 17.2416N 80.1426E<br>
><br>
><br>
> --<br>
> This message has been scanned for viruses and<br>
> dangerous content by MailScanner, and is<br>
> believed to be clean.<br>
<br>
<br>
<br>
Murat BEYHAN<br>
<br>
Jeofizik Y.Müh.<br>
T.C. Başbakanlık<br>
Afet ve Acil Durum Yönetimi Başkanlığı<br>
Deprem Dairesi Başkanlığı<br>
Eskişehir Yolu 12. Km.<br>
Lodumlu/ANKARA<br>
Tel: 312 2872680-1556<br>
<a href="mailto:email%3Abeyhan@deprem.gov.tr">email:beyhan@deprem.gov.tr</a><br>
<br>
<br>
<br>
<br>
--<br>
This message has been scanned for viruses and<br>
dangerous content by MailScanner, and is<br>
believed to be clean.<br>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Best regards,<br>Chaitanya kumar CH.<br><br>+91-9494447584<br>17.2416N 80.1426E<br>