473,805 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Offset to geometry field

Hi,

I am working with MySQL 4.1 and I got a table with a point field. I
need to do an "offset" in all the points, that is, adding some deltaX
to the X coordinate and a deltaY to the Y coordinate.

How can I do this using the update statement?

Feb 3 '06 #1
3 2157
"Otavio Macedo" <ot**********@g mail.com> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
Hi,

I am working with MySQL 4.1 and I got a table with a point field. I
need to do an "offset" in all the points, that is, adding some deltaX
to the X coordinate and a deltaY to the Y coordinate.

How can I do this using the update statement?


Yes, in SQL you can write expressions in UPDATE statements that reference
the fields you're changing:

UPDATE tableName
SET xcoord = xcoord + 47,
ycoord = ycoord - 96;

The example above adds the _same_ offset to all points. If you want to
change each point by a different offset, the easiest way to do it is to
write n UPDATE statements, each with WHERE clauses to affect only the
respective points.

Regards,
Bill K.
Feb 3 '06 #2
OK, Bill, but what I got is a 'point' data type (a descendant of
'geometry' data type). The x and y components are not in separate
fields.

Suppose I create the following table:

CREATE TABLE geotest (
id integer not null primary key,
coord point
);

To insert a new record with coordinates x=12, y=49, for example, I'd
do:

INSERT INTO geotest VALUES (1, pointfromtext(' point(12 49)'));

What I am trying to figure out is how to use the UPDATE statement with
geometry fields, like this one. MySQL provides spatial data support,
but it is still not well documented.

Feb 3 '06 #3
"Otavio Macedo" <ot**********@g mail.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
What I am trying to figure out is how to use the UPDATE statement with
geometry fields, like this one. MySQL provides spatial data support,
but it is still not well documented.


The only way that is apparent to me is (for example, to add +10,+19 to a
coord):

UPDATE geotest
SET coord = PointFromText(C ONCAT('point(', X(coord)+10, ' ', Y(coord)+19,
')')
WHERE id = 12345;

I tried the above and it works.

I also tried a test of something like:

UPDATE geotest SET x(coord) = x(coord)+10;

But that doesn't work. Apparently one cannot use a spatial function as an
lvalue in an UPDATE.

Regards,
Bill K.
Feb 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4546
by: Jon | last post by:
Hello all, I'm certain this question has been asked before; I was unsure what terms to search for within the newsgroup archive to find the proper answer I wanted. Hopefully someone can point me to some relevant postings or websites. In any case, I want to create a geometry class that has some base functionalities. The problem I am particularly interested in is such:
7
9545
by: Maxim Shemanarev | last post by:
I'd like to announce my project called Anti-Grain Geometry. http://www.antigrain.com Anti-Grain Geometry (AGG) is an Open Source, free of charge graphic library, written in industrially standard C++. The terms and conditions of use are very simple and described on the License page. AGG doesn't depend on any graphic API or technology. Basically, you can think of AGG as of a rendering engine that produces pixel images in memory from
11
3480
by: Bradford Chamberlain | last post by:
I work a lot with multidimensional arrays of dynamic size in C, implementing them using a single-dimensional C array and the appropriate multipliers and offsets to index into it appropriately. I tend to iterate over subsets of these arrays by walking a pointer and an offset per dimension across their dimensions. I've found that this tends to result in more performance in a portable manner than doing explicit indexing calculations and...
24
10372
by: funkyj | last post by:
PROBLEM STATEMENT: I want to calculate the byte offset of a field with a struct at compile time without instantiating an instance of the struct at runtime AND I want to do this in an ANSI standard compliant fashion. DISCUSSION: Below is a sample program that demonstrates my solution. My questions are:
7
6592
by: Chris | last post by:
Hi, If a user resizes a Toplevel window, or I set a Toplevel's geometry using the geometry() method*, is there any way to have the geometry reset to that required for all the widgets? I think I found what I'm looking for in tk itself: """ 13.3. How can I clear the geometry settings for a toplevel? If you want to have Tk resize your toplevel to what the toplevel
7
7050
by: p.lavarre | last post by:
How do I vary the byte offset of a field of a ctypes.Structure? How do I "use the dynamic nature of Python, and (re-)define the data type after the required size is already known, on a case by case basis"? \\\ For example, suppose sometimes I receive the value '\x03hi' + \x04bye' for the struct:
12
3911
by: gsal | last post by:
What would be the easiest way to go about offering 3D graphics for the purpose of rendering geometry? Suppose engineers (my co-workes) have to design some enclosure, nozzle, bracket, or whatever physical part/component, I would like to write a program where they can at least see the resulting geometry and navigate it, i.e., zoon-in/out, rotate, pan. On the side, I could have data entry fields with the input parameters and when something...
2
6488
by: JasmynGomez | last post by:
This was an assignment for our JAVA class I am still a beginner and my code keeps getting errors, and I am so confused. I've tried every different way I can think of, can someone please take a look and point out some of the errors. Even just point me to the right direction. I've been working on this for 3 days. HELP!!!!! Write a Geometry Calculator that computes the perimeter and area of the following objects: (a) Trapezoid (general...
3
2796
by: =?ISO-8859-1?Q?Norbert_P=FCrringer?= | last post by:
Hello, do you know an URL for me where to find a sample for an abstract Geometry class, where classes like Point, Line, Area are inherited. This sample should explain OOP (what is inheritance, polymorphism, encapsulation, ...) Thank you, Norbert
0
9718
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10369
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10109
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.