Murat,<div><br></div><div>It's not working. the geom field should not be 'Real'. It should be 'String'. Try something else other than the '+' operator in the SQL syntax to create the geom field in the view.<br>
<br><div class="gmail_quote">On Thu, Mar 1, 2012 at 12:48 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 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 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>
<div class="im"><GeometryType>wkbLineString</GeometryType><br>
<GeometryField encoding="WKT" field="geom"/><br>
</div></OGRVRTLayer><br>
</OGRVRTDataSource><br>
<br>
then the command<br>
<br>
<br>
[murat@localhost stations]$ ogrinfo -ro -al test.vrt<br>
<div class="im">INFO: Open of `test.vrt'<br>
using driver `VRT' successful.<br>
<br>
</div>Layer name: dynamic<br>
Geometry: Line String<br>
<div class="im">Feature Count: 2<br>
Layer SRS WKT:<br>
(unknown)<br>
</div>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 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 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>
<span class="HOEnZb"><font color="#888888"><br>
Murat<br>
</font></span><div class="HOEnZb"><div class="h5"><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 and<br>
> decimals to produce a string.<br>
><br>
> On Wednesday, February 29, 2012, Murat Beyhan <<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 following<br>
> > Roberts' suggestion to create view on database<br>
> ><br>
> > create view lineview as select eq_id, "LINESTRING(" + 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 another<br>
> idea.<br>
> ><br>
> > here is test.vrt file<br>
> ><br>
> > <OGRVRTDataSource><br>
> > <OGRVRTLayer name="sta"><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 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 works....<br>
> ><br>
> ><br>
> > Thanks again<br>
> ><br>
> ><br>
> ><br>
> ><br>
> > On Tue, 2012-02-28 at 18:08 +0530, Chaitanya kumar CH wrote:<br>
> >> Murat,<br>
> >><br>
> >><br>
> >> I see that your view, lineview, doesn't give the expected geometry<br>
> >> type with ogrinfo. It is showing the datatype as Real. 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>
> <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>
> MYSQL:dynamic,user=root,password=mysqlpasswd,host=localhost,port=3306<br>
> >> sfault -summary<br>
> >> INFO: Open of<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, "LINESTRING(" + lon1<br>
> +<br>
> >> " " + lat1<br>
> >> + "," + lon2 + " " + lat2 + ")" as geom from sfault<br>
> >><br>
> >><br>
> >> then<br>
> >><br>
> >> [murat@localhost ~]$ ogrinfo<br>
> >><br>
> MYSQL:dynamic,user=root,password=mysqlpasswd,host=localhost,port=3306<br>
> >> lineview -summary<br>
> >> INFO: Open of<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>
</div></div><div class="HOEnZb"><div class="h5">> --<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"><div><br></div>-- <br>Best regards,<br>Chaitanya kumar CH.<br><br>+91-9494447584<br>17.2416N 80.1426E<br>
</div>