[mapserver-dev] Beginning Mapserver & sql server 2008

Brent Fraser bfraser at geoanalytic.com
Wed Jul 1 11:05:39 EDT 2009


Wesley,

   I'm not familiar with the spatial extensions to Sql Server, but the query 
looks reasonable.  Perhaps you could try a few modifications to the query to see 
if you can narrow down the cause of getting no results.  Something like:

SELECT count(*) from poligonogeom;

or

SELECT geom.STAsText() from poligonogeom;

or

SELECT geom.STAsBinary() from poligonogeom
WHERE geom.STIntersects( Geometry::STGeomFromText('POLYGON(-66 -25, -44 -25, -44 
-8, -66 -8, -66 -25)',0) ) = 1;

or

SELECT geom.STAsBinary() from poligonogeom
WHERE geom.STIntersects( Geometry::STGeomFromText('POLYGON(-66 -25, -44 -25, -44 
-8, -66 -8, -66 -25)',4326) ) = 1;

If this last one works, you may need to add
     PROJECTION
        "init=epsg:4326"
     END
to the MAP portion of your map file.

Best Regards,
Brent Fraser



Wesley wrote:
> Hi Brent,
> 
> I've run the code and I've got the following answer:
> 
> msLoadMap(): 0.016s
> msMSSQL2008LayerOpen called datastatement: geom from poligonogeom
> MSMSSQL2008LayerOpen -- shared connection not available.
> msConnPoolRegister(Camada1,server=luzon2\sqlexpress;uid=sa;pwd=senha1234;database=TESTE;Integrated
> Security=false,020111
> 50)
> msMSSQL2008LayerRetrievePK: query = SELECT     convert(varchar(50),
> sys.columns.name) AS ColumnName, sys.indexes.name FR
> OM         sys.columns INNER JOIN                      sys.indexes
> INNER JOIN                      sys.tables ON sys.ind
> exes.object_id = sys.tables.object_id INNER JOIN
> sys.index_columns ON sys.indexes.object_id = sys.i
> ndex_columns.object_id AND sys.indexes.index_id =
> sys.index_columns.index_id ON                      sys.columns.object_
> id = sys.index_columns.object_id AND sys.columns.column_id =
> sys.index_columns.column_id WHERE     (sys.indexes.is_prima
> ry_key = 1) AND (sys.tables.name = N'poligonogeom')
> msMSSQL2008LayerParseData: unique column = geoid, srid='0',
> geom_column_name = geom, table_name=poligonogeom
> msMSSQL2008LayerFreeItemInfo called
> msMSSQL2008LayerWhichShapes called
> query_string_temp:SELECT geom.STAsBinary(),convert(varchar(20), geoid)
> from poligonogeom WHERE geom.STIntersects(Geometr
> y::STGeomFromText('POLYGON((-66 -25.2431077694236,-44
> -25.2431077694236,-44 -8.75689223057644,-66 -8.75689223057644,-66
> -25.2431077694236))',0)) = 1
> msMSSQL2008LayerFreeItemInfo called
> msMSSQL2008LayerClose datastatement: geom from poligonogeom
> msConnPoolRelease(Camada1,server=luzon2\sqlexpress;uid=sa;pwd=senha1234;database=TESTE;Integrated
> Security=false,0201115
> 0)
> msConnPoolClose(server=luzon2\sqlexpress;uid=sa;pwd=senha1234;database=TESTE;Integrated
> Security=false,02011150)
> msDrawMap(): Layer 0 (Camada1), 0.171s
> msDrawMap(): Drawing Label Cache, 0.000s
> msDrawMap() total time: 0.171s
> msSaveImage() total time: 0.000s
> msFreeMap(): freeing map at 0187A510.
> msMSSQL2008LayerClose datastatement: geom from poligonogeom
> msMSSQL2008LayerClose -- layerinfo is  NULL
> freeLayer(): freeing layer at 01F74160.
> shp2img total time: 0.203s
> 
> 
> When I run the query_string_temp:
> 
> query_string_temp:SELECT geom.STAsBinary(),convert(varchar(20), geoid)
> from poligonogeom WHERE geom.STIntersects(Geometr
> y::STGeomFromText('POLYGON((-66 -25.2431077694236,-44
> -25.2431077694236,-44 -8.75689223057644,-66 -8.75689223057644,-66
> -25.2431077694236))',0)) = 1
> 
> I got no results.
> 
> 
> 
> 2009/6/30, Brent Fraser <bfraser at geoanalytic.com>:
>> Wesley,
>>
>>    Try setting:
>>
>>     IMAGEURL "/ms_tmp/"
>>
>>
>> And to test the rest of your map file, you may want to try Mapserver's
>> command-line companion tool shp2img (ms4w puts it in \ms4w\Apache\cgi-bin):
>>
>>       shp2img -all_debug 5 -m mymapfile.map -o test.gif
>>
>> Best Regards,
>> Brent Fraser
>>
>>
>> Wesley wrote:
>>> Hi all,
>>>
>>> It's my first time with mapserver, and I'm trying to use a map file
>>> connected with sql server 2008. Mapserver is generating a blank image.
>>> I think there is something wrong with my map file below.
>>> Do you have any examples or tutorial about it?
>>>
>>> Thanks,
>>> __________________________________________________________
>>>
>>>
>>> MAP
>>>  NAME "sample"
>>>  STATUS ON
>>>  SIZE 400 300
>>>  IMAGETYPE gif
>>>  EXTENT -66.00 -22.00 -44.00 -9.00
>>>  UNITS DD
>>>
>>> #
>>> # Start of web interface definition
>>> #
>>>  WEB
>>>     TEMPLATE "D:\ms4w\Apache\htdocs\testesql.html"
>>>     IMAGEPATH "D:\ms4w\tmp\ms_tmp\"
>>>     IMAGEURL "/tmp/"
>>>  END
>>>
>>>  LAYER
>>>
>>>   NAME "Camada1"
>>>
>>>   CONNECTIONTYPE PLUGIN
>>>   PLUGIN "D:\ms4w\plugins\msplugin_mssql2008.dll"
>>>
>>>   CONNECTION
>>> "server=luzon2\sqlexpress;uid=sa;pwd=senha1234;database=TESTE;Integrated
>>> Security=false"
>>>
>>>   DATA "geom from lixo"
>>>   TYPE POLYGON
>>>
>>>   STATUS ON
>>>
>>>    PROJECTION
>>>       "init=epsg:4326"
>>>    END
>>>
>>>    CLASS
>>>      STYLE
>>>        COLOR 0 0 255
>>>        WIDTH 8
>>>      END
>>>    END
>>>
>>>  END
>>>
>>> END
>>> _______________________________________________
>>> mapserver-dev mailing list
>>> mapserver-dev at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/mapserver-dev
>>>
> 


More information about the mapserver-dev mailing list