Geoserver - 连接到 SQL Server 2008 Express 并获取数据

发布于 2024-09-25 19:45:43 字数 1193 浏览 5 评论 0原文

-Bref 历史记录:-

我使用的是 MapServer,一切都工作正常,除了当我使用 PixMap 直接在图层上绘制标记时,它被切割在图块之间。因此,我决定更改为 GeoServer,它看起来可以正常工作来绘制图块,其中图块之间有一些图像/像素图。

-历史记录结束-

好的,我可以连接到我的数据存储,即 Ms Sql Server 2008(Express 版)。也许,我无法在 OpenLayer 地图上显示任何内容。

我的数据库中的点示例:

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,边界如下:

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

我是否做错了什么而无法显示任何点?

编辑 这是我的表的定义

id  int (PK)
lon float
lat float
geom    geometry

这是来自 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中。

-Bref history:-

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.

-End of history-

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)

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

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

森林迷了鹿 2024-10-02 19:45:43

对于遇到同样问题的人:

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

事实上,当我将数据库添加到 GeoServer 时,表已设置为 EPSG:0(几何默认值)。但是您需要通过执行如下更新将 EPSG 切换到 4326:

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

之后,删除 GeoServer 中对表的所有引用。您实际上需要从头开始重新创建一切。当您重新添加数据库和表时,它就会起作用。事实上,你会看到“Native-SRC”被自己设置,你也可以点击自动设置你的表的BBOX。 (最小 X、Y、最大 X、Y)

For those who encounter the same issue:

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.

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)

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文