Geoserver-连接到SQL Server 2008 Express并获取数据 [英] Geoserver - Connect to a SQL Server 2008 Express and fetch data

查看:162
本文介绍了Geoserver-连接到SQL Server 2008 Express并获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

-引荐历史记录:-

我使用的是MapServer,一切正常,只是当我使用PixMap在图层上直接绘制标记时,它在图块之间被剪切了.因此,我决定改用GeoServer,它看起来可以正常工作,以便在图块之间有一些图像/像素图的情况下绘制图块.

I was using MapServer, everything was working fine except that when I was drawing a marker directly on a layer using a PixMap it was cut between tile. So, I decided to change to GeoServer which looks to work correctly to draw tiles where you have some image/pixmap between tiles.

-历史记录结束-

好的,我能够连接到我的数据存储,即Sql Server 2008(快速版).也许,我无法在OpenLayer地图上显示任何内容.

Ok, I am able to connect to my data store which is Ms Sql Server 2008 (Express edition). Perhaps, I am not able to show anything on my OpenLayer map.

我的数据库中的点的示例:

Example of point in my database:

POINT (2.66131 48.8792)
POINT (2.66131 48.8792)
POINT (2.67789 48.8982)
POINT (2.67789 48.8982)
POINT (2.70361 48.9402)
POINT (2.76454 48.9866)

在我的GeoServer 2.0.2中,我实际上使用默认样式的点(红色正方形点).这些点在数据库中的EPSG是"4326",在GeoServer的配置中,它也是4326,其边界是这样的:

In my GeoServer 2.0.2, I actually use the default style for point (Red square point). The EPSG of these point in the database is "4326" and in the configuration of GeoServer, it is also 4326 with boundaries like this:

Min X: 2
Min Y: 46
Max X: 8
Max Y: 50

我做错了什么以致无法显示任何分数吗?

Have I done something wrong to not be able to show any points?

编辑 这是我的桌子的定义

Edit Here's the definition of my table

id  int (PK)
lon float
lat float
geom    geometry

以下是来自GeoServer的查询示例:

Here's an example of the query coming from GeoServer:

SELECT "id",CAST("geom".STSrid as VARCHAR) + ':' + "geom".STAsText() as "geom" FROM "TestGeom" WHERE "geom".Filter(geometry::STGeomFromText('POLYGON ((-236.25 -120.234375, -236.25 120.234375, 236.25 120.234375, 236.25 -120.234375, -236.25 -120.234375))', 0)) = 1

仅当我将数据库中的EPSG设置为0时,它才会返回点列表(它们仍不会显示在openlayer的预览"中).如果我将其保留为4326,则不会返回任何内容. geoserver绘制的多边形在EPSG:0中.

It returns a list of points only if I set my EPSG in the database to 0 (they still don't show in the openlayer "preview"). If I leave it at 4326, it returns nothing. The polygon drawn by geoserver is in EPSG:0.

推荐答案

对于遇到相同问题的人:

For those who encounter the same issue:

我找到了它不起作用的原因. "Native-SRC"未正确设置自身(实际上我根本没有任何价值).这实际上是我什么都看不到的主要原因.现在,没有任何理由(或奇迹),在删除所有内容并重新创建所有内容之后,我现在有了一个本机SRC值,并且所有内容均按预期显示.

I found the reason why it was not working. The "Native-SRC" was not setting itself properly (in fact I had no value at all). This is actually the main reason why I wasn't able to see anything. Now for no good reason (or miracle), after removing everything and re-creating everything, I now have a Native SRC value and everything shows up as expected.

实际上,当我将数据库添加到GeoServer时,表的设置是EPSG:0(几何图形的默认值).但是您需要通过执行以下更新将EPSG切换到4326:

In fact the database when I added it to the GeoServer, the tables were setted with EPSG:0 (default for geometry). But you need to switch the EPSG to 4326 by doing an update like this:

update MyTable set MyGeom = geometry::...FromText(MyGeom.STAsText(), 4326)

之后,删除GeoServer中对表的所有引用.实际上,您需要从头开始重新创建所有内容.并且当您将数据库与表重新添加时,它将起作用.实际上,您将看到"Native-SRC"是由其自身设置的,也可以单击表的BBOX的自动设置. (最小X,Y,最大X,Y)

After, remove all the reference in GeoServer to your table. You actually need to recreate everything from scratch. And when you will re-add your database with your table, it will work. In fact, you will see the "Native-SRC" to be set by itself, and you can also click on the autoset the BBOX of your table. (Min X, Y, Max X, Y)

这篇关于Geoserver-连接到SQL Server 2008 Express并获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆