我需要未知数量的坐标字段(或几个字段)如何去做?

发布于 2024-10-20 13:04:50 字数 344 浏览 2 评论 0原文

使用 MySQL 我需要一个 x,y 坐标列表(可能很长)。我该怎么办?

对于这个问题中令人惊讶的含糊之处,我们深表歉意!我不想解释我的整个项目,但我想更多的解释是为了让这个问题变得有意义。

好吧,我正在为客户做一个地图/方向网络应用程序(不,我研究过 Google 地图 API,但我需要绘制他们的建筑物/校园的地图,所以我认为这不太适用)。所以我目前的计划是创建一些 PHP 脚本,这些脚本将通过 dijkstra 的算法运行(我故意将其简化很多,因为我不想解释整个项目),但由于该算法是基于使用图表我将有一个包含各种坐标的边缘表,以便我知道在图像中如何绘制线条。现在这对你们来说更有意义了吗?我再次道歉,我最初应该更深入地讨论我的问题。

Using MySQL I need to have a list (possibly long list) of x,y coordinates. How should I go about this?

Apologies for the amazing amount of vague in this question! I didn't want to explain my entire project but I suppose some more explanation is in order for this to make any sense as a question.

Ok I'm doing a a map/direction web application for a client (no, I've looked into Google Maps API, but I need to map their buildings/campus so I don't think that applies well). So my current plan is to create some PHP scripts that will run through dijkstra's algorithm (I'm purposely dumbing this down quite a bit because, again, I don't want to explain the whole project) but since that algorithm is based on the use of a graph I was going to have an Edge table that will contain various Coords so that I know, in the image, how to draw my lines. Does this make any more sense to you guys now? Again I apologize, I should've gone a little more into my issue originally.

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

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

发布评论

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

评论(2

乜一 2024-10-27 13:04:50

由于您的问题很模糊,所以做出了很多假设...

使用两个带有外键的表,这是建模一对多关系的标准方法

create table table1 (
id int
--more columns presumably
)
create table coordinates (
id int,
table_id int --foreign key with table1,
x int,
y int
)

making a lot of assumptions since your question is vague...

Use two tables with a foreign key, this is the standard approach to model a one to many relationship

create table table1 (
id int
--more columns presumably
)
create table coordinates (
id int,
table_id int --foreign key with table1,
x int,
y int
)
萧瑟寒风 2024-10-27 13:04:50

MySQL是一个存储数据的数据库。您可以创建一个包含 XCoord 和 YXoord 字段的表,该表可以轻松处理数百万行。

CREATE TABLE Coordinates( id int(11) NOT NULL Auto_increment,
  X double NOT NULL,
  Y double NOT NULL,
PRIMARY KEY (id)
)

MySQL is a database which, stores data. You can create a table with XCoord and YXoord fields which can handle millions of rows with ease.

CREATE TABLE Coordinates( id int(11) NOT NULL Auto_increment,
  X double NOT NULL,
  Y double NOT NULL,
PRIMARY KEY (id)
)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文