Murat,<div><br></div><div>I see that your view,
lineview, doesn't give the expected geometry type with ogrinfo. It is showing the datatype as Real. Check if the datatype of geom is actually string/text.<br><br><div class="gmail_quote">On Tue, Feb 28, 2012 at 12:49 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>
<br>
Map file which is try to draw line as follows<br>
are there any problem on the code<br>
<div class="im"><br>
LAYER<br>
NAME sfault1<br>
CONNECTIONTYPE OGR<br>
CONNECTION '<OGRVRTDataSource><br>
<OGRVRTLayer name="lineview"><br>
</div><SrcDataSource>MYSQL:dynamic,user=root,password=mysqlpasswd,host=localhost,port=3306,tables=lineview</SrcDataSource><br>
<div class="im"> <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>
</div>ogrinfo<br>
MYSQL:dynamic,user=root,password=mysqlpasswd,host=localhost,port=3306<br>
sfault -summary<br>
INFO: Open of<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 statement:*************<br>
<div class="im"><br>
<br>
create view lineview as select eq_id, "LINESTRING(" + lon1 + " " + lat1<br>
+ "," + lon2 + " " + lat2 + ")" as geom from sfault<br>
<br>
</div>then<br>
<br>
[murat@localhost ~]$ ogrinfo<br>
MYSQL:dynamic,user=root,password=mysqlpasswd,host=localhost,port=3306<br>
lineview -summary<br>
INFO: Open of<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>
as you see there is no problem to connect mysql and read information<br>
created mysql geometries from shape file also works here is an example<br>
<br>
[murat@localhost ~]$ ogrinfo<br>
MYSQL:testogr,user=root,password=mysqlpasswd,host=localhost,port=3306<br>
iller -summary<br>
INFO: Open of<br>
`MYSQL:testogr,user=root,password=mysqlpasswd,host=localhost,port=3306'<br>
using driver `MySQL'<br>
successful.<br>
<br>
Layer name: iller<br>
Geometry: Polygon<br>
Feature Count: 83<br>
Extent: (26.026489, 35.820221) - (44.869179, 42.094917)<br>
Layer SRS WKT:<br>
GEOGCS["GCS_WGS_1984",<br>
DATUM["WGS_1984",<br>
SPHEROID["WGS_1984",6378137,298.257223563]],<br>
PRIMEM["Greenwich",0],<br>
UNIT["Degree",0.0174532925199433]]<br>
FID Column = OGR_FID<br>
Geometry Column = SHAPE2<br>
area: Real (13.6)<br>
perimeter: Real (13.6)<br>
illerdd_: Real (0.0)<br>
illerdd_id: Real (0.0)<br>
il_kod: Real (2.0)<br>
iladi: String (20.0)<br>
[murat@localhost ~]$<br>
<br>
<br>
<br>
Now I would like to learn what is wrong with my procedures... please<br>
help<br>
<br>
<br>
<br>
Murat<br>
<div><div class="h5"><br>
<br>
On Tue, 2012-02-28 at 09:03 +0530, Chaitanya kumar CH wrote:<br>
> Murat,<br>
><br>
><br>
> Since it is MySQL it doesn't matter much how you store it. If you are<br>
> going to edit the end points later, storing them as points is<br>
> preferable, otherwise store them as wkt linestring geometries.<br>
><br>
><br>
> For your mapfile, first check if the extents are correct. Then check<br>
> if the mapfile works with a shapefile created from the geometries in<br>
> MySQL.<br>
><br>
> On Tuesday, February 28, 2012, Murat BEYHAN wrote:<br>
> Chaitanya,<br>
><br>
> thanks for your repply,<br>
><br>
> Actually I use ogr and mysql to draw point for example<br>
> epicenter of<br>
> earthquakes. But this is the first time to draw line which is<br>
> stored in<br>
> Mysql as a table. Actually there is no problem on drawing<br>
> shape file of the<br>
> line. But I would like to draw it using MySql and ogr<br>
> functionality. So I<br>
> have only start and end point of line and I store it on MySql<br>
> database then<br>
> I try to draw it considering id of the line by sql statement.<br>
> Just I would lie to learn how to code it on Mapserver map file<br>
> and how<br>
> should I store line on database as a start and stop point of<br>
> the line or as<br>
> a geometry . Please help...<br>
> thanks<br>
><br>
><br>
><br>
><br>
> On Mon, 27 Feb 2012 22:09:52 +0530, Chaitanya kumar CH wrote<br>
> > Murat,<br>
> ><br>
> > First check if your database is accessible using ogrinfo[1].<br>
> > Then create a vrt file with the content you specified in the<br>
> CONNECTION<br>
> > field of the mapfile. Check if ogrinfo gives expected<br>
> results with this<br>
> > file.<br>
> ><br>
> > You probably have gdal executables if you are running<br>
> mapserver.<br>
> ><br>
> > [1]: <a href="http://www.gdal.org/ogrinfo.html" target="_blank">http://www.gdal.org/ogrinfo.html</a><br>
> ><br>
> > On Mon, Feb 27, 2012 at 12:48 PM, Murat Beyhan<br>
> > <<a href="mailto:beyhan@deprem.gov.tr">beyhan@deprem.gov.tr</a>> wrote:<br>
> ><br>
> > > Dear all,<br>
> > > I have shared this mail on Mapserver list but could not<br>
> solve my<br>
> > > problem.<br>
> > > Still could not achieve to draw line using start and stop<br>
> point line<br>
> > > data stored in MySql database.<br>
> > ><br>
> > > I have tried Mr. Robert's solution but I have faced an<br>
> error message.<br>
> > ><br>
> > ><br>
> > > in map file<br>
> > > I changed Geometrytype from wkbline to wkblinestring.<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,po<br>
> rt=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>
> > > in database<br>
> > > I have two table<br>
> > > one is sfault which store<br>
> > ><br>
> > > id lat1 lon1 lat2 lon2<br>
> > ><br>
> > > and another is lineview which is a view<br>
> > > of this table created by following<br>
> > ><br>
> > > create view lineview as select eq_id, "LINESTRING(" + lon1<br>
> + " " + lat1<br>
> > > + "," + lon2 + " " + lat2 + ")" as geom from sfault<br>
> > ><br>
> > ><br>
> > > there is an another issue,<br>
> > ><br>
> > > I have to draw line by considering id<br>
> > > so in the map When I select one id, line should be belong<br>
> to this id's<br>
> > > information<br>
> > > so I have to make a sql statement as follow instead of<br>
> draw all line<br>
> > > stored in database I have to draw just one line<br>
> considering id<br>
> > ><br>
> > > something like this:<br>
> > ><br>
> > > select eq_id, geom from lineview where id like '%id%'<br>
> > ><br>
> > ><br>
> > > please help about this subject....<br>
> > ><br>
> > ><br>
> > > Regards....<br>
> > ><br>
> > ><br>
> > ><br>
> > > Murat<br>
> > ><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>
> > > gdal-dev mailing list<br>
> > > <a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
> > > <a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><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>
> > This message has been scanned for viruses and<br>
> > dangerous content by MailScanner, and is<br>
> > believed to be clean.<br>
><br>
><br>
> Murat Beyhan<br>
> Jeofizik Yük. Müh.<br>
> T.C.<br>
> BAŞBAKANLIK<br>
> Afet ve Acil Durum Yönetimi Başkanlığı<br>
> Deprem Dairesi Başkanlığı<br>
> Eskişehir Yolu 12. Km. Lodumlu/Ankara<br>
> Tel:+90 (312) 2872680-1550<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>
> 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>
> This message has been scanned for viruses and<br>
> dangerous content by MailScanner, and is<br>
> believed to be clean.<br>
<br>
<br>
<br>
</div></div>Murat BEYHAN<br>
<br>
Jeofizik Y.Müh.<br>
T.C. Başbakanlık<br>
<div class="im">Afet ve Acil Durum Yönetimi Başkanlığı<br>
Deprem Dairesi Başkanlığı<br>
Eskişehir Yolu 12. Km.<br>
</div>Lodumlu/ANKARA<br>
Tel: 312 2872680-1556<br>
<a href="mailto:email%3Abeyhan@deprem.gov.tr">email:beyhan@deprem.gov.tr</a><br>
<div class="HOEnZb"><div class="h5"><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>