There's more to experience when you log in!
Over the coming weeks, I'll write a #series of articles about the #SQL improvements we have made in MapInfo Pro v2019. A big part of this will be the Select statement but we have also made a number of other improvements that I'll cover.
You could in earlier versions of MapInfo Pro calculated derived spatial objects and use these in your statement. But you couldn't display the derived spatial object in a map window. Here you would always see the object from the primary table of your query.
In MapInfo Pro v2019, we have added the new Object keyword to use in Select statements when your projection list returns multiple objects, either implicitly or explicitly. You place the keyword after the object expression that you want to use as the spatial object in your query result:
Select <some object returning expresssion> Object
You can use the keyword after an obj column. If you only are selecting from one table, this is not necessary. If you are selecting from multiple tables, you can use the Object keyword to control from which table, you want to use the spatial object.
You can also use the Object keyword after a spatial function that returns a spatial object. This lets you calculate new spatial objects and use these in the query result.
You cannot use the Object keyword after a spatial aggregate. You can only use one spatial aggregate in a query and that is the only spatial element returned.
In this first example, we will use the Object keyword to highlight the points selected by the query. Often when you select points, it can be hard to see where they are located. You can use the Buffer function to convert the points to a polygon and so highlight the area.
In this example, we select all the address points for a specific road. To all the columns in the table, we add a buffer expression that creates a 10-meter buffer around the points. We use the Object keyword for the buffer expression to use this object instead of the points from the input table.
Select a.*, CartesianBuffer(a.Obj, 24, 10, "m") Object
From Addresses As "a"
Where a.StreetName = "Søndervang"
In the map below, you can see how the buffer highlights the address points. For the query, we also specified that the query should get added to the map with a specific override color and we enabled the Zoom to Selection too.
In this example the input objects where points, but you can also use this method for other object types like (poly)lines and polygons.
Select p.*, z.planid, z.plannavn, Overlap(p.obj, z.obj) Object
From Parcels As "p", Selection As "z"
Where p.Obj Intersects z.Obj
In the map, I have highlighted the resulting polygons with a thick orange line and orange horizontal pattern. I have manually selected the overlap inside parcel 1hb so that you can see it's not connected to the rest.
In this third and final example, we will use the Object keyword to highlight the spatial relation between objects that are near each other. We are also using some other improvements around joins that I will cover in another post.
The query below lets you see the spatial relationship as a straight line between the two objects that are joined. The join condition is here defined as objects that are closer than 500 meters from each other.
The query finds addresses near a selected object. In my example, I'm looking for addresses near a specific lake. I select the lake using the selector and then I run the query. In the SQL Window, I have specified that the result should be added to my map with a red override color.
Select a.*, CartesianConnectObjects(l.Obj, a.Obj, 1) Object
From Selection As "l", Addresses As "a"
Where CartesianObjectDistance(l.obj, a.obj, "m") < 500
I hope you have found this useful. Let us know if you have specific queries, that would like to perform. Maybe we can help you create these.
Stay tuned for the next post next week!