Skip to main content
Question

Reading multiple geometry using sql executor


f.kemminje
Contributor
Forum|alt.badge.img+11

Can I read multiple geometry using sqlexecutor. In my case , i dont have two geometry in one table. i am extracting/constructing multiple (2) geometry from different tables and the sql gives resultset with two geometries in one row.

two geometry from sql resultset not from one table

and later i will deaggregate this and use these geometries for different purposes.

how can i achieve this using fme?

13 replies

david_r
Celebrity
  • September 28, 2017

Which database are you using and how are the geometries stored?

One solution could be to cast both geometries to e.g. WKB and then use two separate GeometryReplacers to extract the geometries. Something like (pseudo-code):

select 
  as_binary(t1.geom) as geom1, 
  as_binary(t2.geom) as geom2
from 
  mytable1 t1 join mytable2 t2 on t1.id=t2.id

Then expose "geom1" and "geom2" and send them to the GeometryReplacer as OGC Well-Known Binary.


f.kemminje
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • September 28, 2017
david_r wrote:

Which database are you using and how are the geometries stored?

One solution could be to cast both geometries to e.g. WKB and then use two separate GeometryReplacers to extract the geometries. Something like (pseudo-code):

select 
  as_binary(t1.geom) as geom1, 
  as_binary(t2.geom) as geom2
from 
  mytable1 t1 join mytable2 t2 on t1.id=t2.id

Then expose "geom1" and "geom2" and send them to the GeometryReplacer as OGC Well-Known Binary.

@david_r oracle sql says as_binary invalid identifier

 

 

as_binary

 


erik_jan
Contributor
Forum|alt.badge.img+18
  • Contributor
  • September 28, 2017

Why do you need to use the SQLExecutor transformer and not an Oracle Spatial reader or the FeatureReader.

In your case the SQLExecutor seems to complicate matters only.


david_r
Celebrity
  • September 28, 2017

For Oracle Spatial, use:

SDO_UTIL.TO_WKBGEOMETRY(geom)

Doc: https://docs.oracle.com/cd/B28359_01/appdev.111/b28400/sdo_util.htm#SPATL1250

For ArcSDE with an Oracle backend, use:

sde.st_asbinary(geom)

Doc: http://desktop.arcgis.com/en/arcmap/10.3/manage-data/using-sql-with-gdbs/st-asbinary.htm


david_r
Celebrity
  • September 28, 2017
erik_jan wrote:

Why do you need to use the SQLExecutor transformer and not an Oracle Spatial reader or the FeatureReader.

In your case the SQLExecutor seems to complicate matters only.

It's pretty handy if you need to join several tables and haven't got the option of creating a view in the database.

david_r
Celebrity
  • September 28, 2017
f.kemminje wrote:
@david_r oracle sql says as_binary invalid identifier

 

 

as_binary

 

It's pseudo-code, you'll have to replace that with whatever your backend supports.

f.kemminje
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • September 28, 2017
erik_jan wrote:

Why do you need to use the SQLExecutor transformer and not an Oracle Spatial reader or the FeatureReader.

In your case the SQLExecutor seems to complicate matters only.

i extractring the data by joining many tables. i use oracle spatial.

 

 

 


f.kemminje
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • September 28, 2017

@david_r

my database is oracle spatial


erik_jan
Contributor
Forum|alt.badge.img+18
  • Contributor
  • September 28, 2017
erik_jan wrote:

Why do you need to use the SQLExecutor transformer and not an Oracle Spatial reader or the FeatureReader.

In your case the SQLExecutor seems to complicate matters only.

OK, I can see the point.

 

But in this example I would use two SQLCreators (not SQLExecutors), each with a query containing 1 geometry.

 

No need to de-aggregate afterwards.

 

 


f.kemminje
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • September 28, 2017

@david_r

Thank you David.


david_r
Celebrity
  • September 28, 2017
erik_jan wrote:
OK, I can see the point.

 

But in this example I would use two SQLCreators (not SQLExecutors), each with a query containing 1 geometry.

 

No need to de-aggregate afterwards.

 

 

Not sure I follow. You mean doing the join in the workspace rather than in the database?

erik_jan
Contributor
Forum|alt.badge.img+18
  • Contributor
  • September 28, 2017
david_r wrote:
Not sure I follow. You mean doing the join in the workspace rather than in the database?
Yes, if needed. But according to the question, two geometries are read, aggregated by the read and afterwards de-aggregated to be used separately. If used separately, why join in the first place?

 

 


david_r
Celebrity
  • September 28, 2017
erik_jan wrote:
Yes, if needed. But according to the question, two geometries are read, aggregated by the read and afterwards de-aggregated to be used separately. If used separately, why join in the first place?

 

 

Ah, I see. I must admit I didn't take the "aggregate" bit literally in this context.

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings