Sdo_relate: combined masks
Hi,
I would like to execute a sdo_relate operation with a combined mask like (CONTAINS+COVERS+OVERLAPBDYINTERSECT)
but it gives me not all results (I checked
it with sdo_geom.relate). Furthermore when I
swap the masks in the parenthesis it gives
me no results at all.
I think I have seen an information somewhere
which said that this is a known bug.
If this is a bug is there a patch available
for it?
I'm working with 8.1.7.
Joerg
Hi,
the solution I am using is as follows:
SELECT x.*
FROM (SELECT sdo_geom.relate(a.geo, m.diminfo, 'determine', b.geo, m.diminfo) rel,
FROM a, b, user_sdo_geo_metadata m
WHERE mdsys.sdo_relate(a.geo,b.geo,
'MASK=ANYINTERACT QUERYTYPE=JOIN') = 'TRUE'
...) x
WHERE x.rel != 'TOUCH'
This finds all objects which have common area. I use a relate operator with the ANYINTERACT mask to find all object which
have a spatial relationship. Then I determine
the relationship with the relate function. In
the surrounding SELECT I filter out all objects
with a 'TOUCH' relationship.
For me this is much faster than the Query
with a UNION.
Anyway, this is just a workaround.
Joerg
Similar Messages
-
Ques on SDO_RELATE with mask as "TOUCH
A Question on "SDO_RELATE" with mask as "TOUCH".
We do a SDO_RELATE Operation on two SDO Layer, to find all those polygons, which comes from different SDO Layer and share a common edge.
We using "SDO_RELATE(t2.geom,t1.geom,'mask=TOUCH querytype=JOIN')='TRUE'", it found what we needed , however at the same time , those polygons from two different sdo table which share only a common point is also included in the selection. How to limited selection to those only share a common edge.
Richard LeeYou might try intersecting the two geometries that touch. If a point geometry is returned then you can eliminate it.
The touch mask itself is working correctly - it won't discriminate between touch at a point, and touch along an edge.
Hope this helps. -
SDO_FILTER and SDO_RELATE combined in the same query
Is it possible to combine these two operations?
I have a query that ideally should use SDO_RELATE for polygon data (some 25 million records). However it takes too long to run.
For curiosity's sake I tried using SDO_FILTER and again this takes hours. Again for curiosity's sake I combined the two and records are returned in about 2 mins. Please see the query below (to simplify matters I have used point data).
SELECT
FROM
table t
WHERE
MDSYS.SDO_RELATE(
t.geometry,
MDSYS.SDO_GEOMETRY( 2001,
null,
MDSYS.SDO_POINT_TYPE( 501900, 308000, null ),
null,
null
'mask=anyinteract querytype=WINDOW'
) = 'TRUE'
AND MDSYS.SDO_FILTER(
t.geometry,
MDSYS.SDO_GEOMETRY( 2001,
null,
MDSYS.SDO_POINT_TYPE( 501900, 308000, null ),
null,
null
'mask=anyinteract querytype=WINDOW'
) = 'TRUE'
As I see it, in this case SDO_FILTER is doing the primary filtering part. SDO_RELATE is doing primary filtering again followed by secondary filtering the resulting data which is why it is quicker. The data does appear to be correct.
Now am I barking up the wrong tree? Whether I am or not, why is this combination faster than individual use? I would appreciate any thoughts on this please.
Cheers guys
Jamessomething else is going on, although without seeing the real query it is hard to know.
SDO_RELATE is a supoerset of SDO_FILTER. With SDO_FILTER and index query is done, with SDO_RELATE an index query is done, then the relate is done on the geometries returned by the filter query.
What kind of index are you using?
What version of spatial are you using?
Can you post the query window?
Are your geometries valid? -
SDO_RELATE - EQUAL MASK - Different results on the same query
Hello.
I'm trying to find all spatial duplication in the point layer (using certain tolerance). That layer has q-tree spatial index and appropriate tolerance in the user_sdo_geom_metadata table (let's say 1 meter). I have SDO_VERSION=9.2.0.5.0.
To perform that I use SDO_RELATE operator with EQUAL mask (I know that actually I can use other operators but lets consider EQUAL):
SELECT /*+ ordered */t1.OBJECTID, /*+ ordered */t2.OBJECTID from points_table t1, points_table t2 WHERE t1.OBJECTID < t2.OBJECTID
AND sdo_relate (t2.shape, t1.shape, 'mask=EQUAL querytype = JOIN') = 'TRUE'
The problem is:
If I create Q-tree index using SDO_LEVEL=8 query takes 10 minutes and returns lets say 1000 dup events
If I create Q-tree index using SDO_LEVEL=10 query takes 20 seconds and returns lets say 996 dup events
I'm confusing about that - Why the results are depend from SDO_LEVEL? For me it is more important then performanse.
Those missed duplication events are really duplication events (point closer to each other than 1 meter) and SDO_DISTANSE for those particlar poins returns 0. It is correct, but SDO_RELATE monitors that those points are not equal.
So how can I rely on the SDO_RELATE function? What SDO_LEVEL need I use to get correct results? I choosed Q-tree indexes because of performance I didn't get success to get result using R-tree indexes on big datasets at all.
Regarding polylines:
I suppose that I can get similar problem and for polylines (Im also using same query to find dups polylines).
Sometimes SDO_RELATE finds polylines which ones are not really equal in the specified tolerance (1 meter). All cases that I saw it was simple segments which ones share only one vertex but the other ends are spatially disjoint more that 3 meters. Why SDO_RELATE finds such cases as EQUAL?
Thank you very much in advance.Thank you Siva for advice.
I've tried R-tree indexes and got reasonable performance on the tables with ~20k rows.
But when I try to ran that query on the table (points) with 250k rows it takes forever :(.
1) Create index:
Create index nodes_idx on nodes(SHAPE) indextype is mdsys.spatial_index parameters ('LAYER_GTYPE=POINT initial=10m next=5m sdo_rtr_pctfree=10 pctincrease=0');
/* actually 'initial=10m next=5m sdo_rtr_pctfree=10 pctincrease=0' options only decreased slightly performance */
2) Execute query:
SELECT /*+ ordered */t1.OBJECTID, /*+ ordered */t2.OBJECTID
from nodes t1, nodes t2 WHERE t1.OBJECTID < t2.OBJECTID AND
sdo_relate (t2.shape, t1.shape, 'mask=EQUAL querytype = WINDOW') = 'TRUE'
Plan Explanation:
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 150M | 1095G| 505M|
| 1 | NESTED LOOPS | | 150M| 1095G| 505M |
| 2 | TABLE ACCESS FULL | NODES | 548K | 2043M| 411 |
| 3 | TABLE ACCESS BY INDEX ROWID| NODES | 274 | 1047K| 505M|
| 4 | DOMAIN INDEX | NODES_IDX | 27416 | | |
As far as I understand, oracle reserved for that query 1095G of memory?! Is it really necessary for that simple query and how can it be possible?
Regards, Denis.
Message was edited by:
Tenek -
Clipping Mask: "Group" Transform Controls
I'm using a clipping mask to size a pictures in a collage, and after I have positioned my photo in the mask (both the photo and the mask are in a "group"), I would like to resize the "group", but the transform controls (and associated information in the "Info" tab) default to the underlying picture, not the mask.
Is there a way to make the group controls default to the mask, not the photo? (Note: If I select the mask within the group, I can then move and resize, but it only moves and resizes the mask, not the combined mask/photo.)
Thanks in advance!
BrianMaybe i'm not reading your question right, but anyway if your clipped
layers are the only ones in the group, then make the group active in the
layers panel and press Ctrl+T to transform the whole group.
(the shape 1 layer is the mask layer in this example)
If you have more than just the clipped layers in the group, select only the clipped
layers and then Ctrl+T (Edit>Free Transform).
If your using the move tool to select the layers, then options you have set
in the tool options bar have to do with how layers or groups are selected
when clicking in the document area.
http://help.adobe.com/en_US/photoshop/cs/using/WSfd1234e1c4b69f30ea53e41001031ab64-78d1a.h tml
MTSTUNER -
Hi,
I have about 10 layers that I want to merge together. Each layer has its own individual alpha mask that doesn't overlap each other. I was wondering if it's possible to merge all the layers onto one while preserving an alpha that encompasses all 10 alpha masks as well.
Thanks.I am not sure how the merged alpha channel will help you and I am pretty sure if you applied that combined alpha channel as a layer mask on the merged images that you would not get the same result as a Merge operation (Michael already mentioned this above). In the layer stack, each Layer Mask operates wtih the existing layer and the next lower layer (with all other layer settings) to determine the Composite image to present to the next higher Layer and Layer Mask. The masks are not directly working in a cascade fashion with each other directly from a conceptual point of view (IMHO of course). That is why preserve only keeps the bottom Layer Mask. All the other masks were merged into their respective Layers druing the merge process (except the last one).
That given, if you want to create a composite mask for some purpose that I do not understand (very likely) then here is how you can do it:
- Make sure that selections are cleared
- On each Layer, add the Layer Mask to the selection
- After all Layer Masks have been added to the selection, either a) save selection as a) Channel Mask or b) create a new Layer Mask on its own independent layer from the selection.
At this point you have the combined mask as you requested either in the channels panel or as an independent layer mask. You can do the merge without preserve set and still have a combined mask as you requested to be used whereever.
Hope this is helpful and if I just don't understand your request I apologize for taking up your time. If I am off base, it may be helpful to describe what you want to achieve with your image as opposed to just what operations you want to execute. I sense other forum members don't quite understand the end result you want to achieve. I am sure you will get lots of suggestions once forum members understand the end image objectives. Good luck. -
How to find a line/edge that starts at the same point as the end of another
I have an edges table of Lat/Lon data and for a specific edge I want to find any other edges that have the same start point as the end point of the given edge.
I tried the following query:
select geo_street_id from geo_street s2
where SDO_LRS.GEOM_SEGMENT_START_PT(s2.geom) =
(select SDO_LRS.GEOM_SEGMENT_END_PT(s.geom) as geom from geo_street s
where geo_street_id = 122978214)
but it gets the following error:
ORA-22901: cannot compare nested table or VARRAY or LOB attributes of an object type
Any Ideas?1. to compare geometry to be equal you should use appropriate function (SDO_GEOM.RELATE http://download.oracle.com/docs/html/B14255_01/sdo_objgeom.htm#sthref1561) or operators (sdo_relate http://download.oracle.com/docs/html/B14255_01/sdo_operat.htm#i78531) with specific mask EQUAL.
2. to filter down the resultset in first place you can use the operator SDO_RELATE with mask TOUCH as this will return already the set of lines sharing endpoints, but will also include lines touching eachother not at endpoints (endpoint intersecting the otherone's interior)
something like
select geo_street_id from geo_street s2, geo_street s
where
s.geo_street_id = 122978214
AND
sdo_relate(s2.geom, s.geom,'mask=touch') = 'TRUE'
AND
sdo_geom.relate(SDO_LRS.GEOM_SEGMENT_START_PT(s2.geom),
'EQUAL',
SDO_LRS.GEOM_SEGMENT_END_PT(s.geom),0.005)='EQUAL'
3. if you would do this for the full table, an SDO_JOIN (http://download.oracle.com/docs/html/B14255_01/sdo_operat.htm#BGEDJIBF) might be more appropriate.
4. you might also consider 4 cases:
start = start
start = end
end = start
end = end
5. alternative would be to take only the endpoints of your selected geometry and perform a touch with the edges. using the sdo_util.APPEND on the startpoint en endpoint of your geometry will return a multipoint. although there might some specific cases that this would not return respected result I think
something like:
select geo_street_id from geo_street s2, geo_street s
where
s.geo_street_id = 122978214
AND
sdo_relate(s2.geom,
SDO_UTIL.APPEND(
SDO_LRS.GEOM_SEGMENT_START_PT(s.geom),
SDO_LRS.GEOM_SEGMENT_END_PT(s.geom)
,'mask=touch') = 'TRUE'
Let us know how it works.
Luc -
Extract Filter is sorely missed.
Can anyone tell me why Adobe doesn't want us using the Extract filter? Was it created by someone they don't like? Some copyright issue? There is nothing that works like it or replaces it. I am very frustrated! I am creating my psd files in CS4, then opening in CS6 to do the rest. I WANT MY EXTRACT FILTER BACK!
As far as I can tell one cannot save intermediate steps with Extract per se.
But quite frankly I have a hard time imagining what image/task would justify spending two contiguous hours in that feature.
Maybe you could work around it with the old Channel-methods or combine Masks arrived at both from extract as well as the various Selection-methods. -
Hi, instruction for to work this script : http://www.russellbrown.com/images/tips_downloads/Adobe_Edit_in_ACR_Installer.zip please?
Video with the instruction don't workAbout that download. Its designed for a particular version of Photoshop and installed through Adobe extension manager. Actually the script will actually work with several version of Photoshop even CC. However in CC ACR is also a Photoshop Filter therefor the script should not be used with CC. I have used a version of the script in CS6 and CS5. It will not work in CS2 it may work in CS3 and CS4. Adobe extension manger install ZXP files are zip files and you can rename them to zip and extract the files in the package. You only need the script file "Adobe ACR Editor.jsx" just copy that file to Photoshop Presets\Scripts\ folder.
The way the script works is it replaces the layer you want to edit in ACR with a placed in Tiff File the script the script creates from the active layer then adds back ant layer masks. If you want edit a composite of layers convert the group of layer into a smart object layer first. ACR Preferences must be set to Open Tiff files in ACR and resolution needs to be 300DPI.
// c2011 Adobe Systems, Inc. All rights reserved.
// Produced and Directed by Dr. Brown ( a.k.a Russell Preston Brown )
// Written by Tom Ruark because I wrote listener! I get credit for all listener code.
@@@BUILDINFO@@@ Adobe ACR Editor.jsx 1.1.7
// enable double clicking from the Macintosh Finder or the Windows Explorer
#target photoshop
// save some state so we can restore
// we pop the ACR dialog so users can cancel out and we are in a bad state
var historyDocument = app.activeDocument;
var historyState = app.activeDocument.activeHistoryState;
var isCancelled = true;
app.activeDocument.suspendHistory( 'Adobe ACR Editor', 'EditLayerInACR();');
if( isCancelled ){
if (historyDocument != app.activeDocument) {
app.activeDocument.close( SaveOptions.DONOTSAVECHANGES );
app.activeDocument = historyDocument;
app.activeDocument.activeHistoryState = historyState;
isCancelled ? 'cancel' : undefined;// do not localize cancel
function EditLayerInACR(){
// Show this message just once.
// If I have preferences then I must of done this already.
var message = "Special Instructions\r";
message += "Make sure that you have set your Camera Raw Preferences to the following setting:\r";
message += "(Automatically open all supported TIFFs)\r";
message += "To access this preference setting, go to your Main Menu and select: Photoshop/Preferences/Camera Raw\r";
message += " \rAlso, your default resolution for TIFF images in ACR must be set to 300ppi. If you see your layers change in size, then you know that your resolution is not set correctly.\r";
message += "";
var optionsID = "5714ecb5-8b21-4327-bf64-135d24ea7131";
var showMessage = true;
try {
var desc = app.getCustomOptions(optionsID);
showMessage = false;
catch(e) {
showMessage = true;
if (showMessage) {
alert(message);
var desc = new ActionDescriptor();
desc.putInteger(charIDToTypeID('ver '), 1);
app.putCustomOptions(optionsID, desc);
var tempName = "Raw Smart Temp";
var tempFile = new File( Folder.temp.toString() + "/" + tempName + ".tif" );
if( tempFile.exists ) tempFile.remove();
try {
// make sure active layer is a normal art layer
if( app.activeDocument.activeLayer.typename != 'ArtLayer' || app.activeDocument.activeLayer.kind != LayerKind.NORMAL ) return 'cancel';
// change image res to match defalut ACR 300
if( app.activeDocument.resolution != 300 ) {
var docRes = app.activeDocument.resolution;
app.activeDocument.resizeImage(undefined, undefined, 300, ResampleMethod.NONE);
var channelMask = hasChannelMask();
var vectorMask = hasVectorMask();
var layerTransparency = HasLayerTransparency();
// save then remove channel mask if exists
if( channelMask ) {
var channelMaskSettings = getChannelMaskSettings();
var tempAlpha = channelMaskToAlphaChannel();
deleteChannelMask();
// save then remove vector mask if exists
if( vectorMask ) {
var vectorMaskSettings = getVectorMaskSettings();
app.activeDocument.pathItems[app.activeDocument.pathItems.length-1].duplicate( 'tempPath' );
app.activeDocument.pathItems[app.activeDocument.pathItems.length-1].remove();
if( layerTransparency ) {
var layerName = app.activeDocument.activeLayer.name;
recoverLayerAndSave();
convertLayerToACRSmartObject();
if( layerTransparency && !channelMask ) {
// create a channel mask from original layer transparency
var transMask = app.activeDocument.channels.getByName( "7d358230-8855-11de-8a39-0800200c9a66_Alpha" );
alphaToChannelMask( transMask );
transMask.remove();
// restore channel mask if needed
if( channelMask ) {
//restore the saved channel mask
alphaToChannelMask( tempAlpha );
setChannelMaskDensity( channelMaskSettings.density );
setChannelMaskFeather( channelMaskSettings.feather );
tempAlpha.remove();
if( layerTransparency ) {
// combine masks
var transMask = app.activeDocument.channels.getByName( "7d358230-8855-11de-8a39-0800200c9a66_Alpha" );
combineChannelMaskWithAplha( transMask );
transMask.remove();
// restore vector mask if needed
if( vectorMask ) {
app.activeDocument.pathItems['tempPath'].select();
createVectorMask();
setVectorMaskDensity( vectorMaskSettings.density );
setVectorMaskFeather( vectorMaskSettings.feather );
app.activeDocument.pathItems['tempPath'].remove();
// well at least this is the same!
// replace contents of selected smart object
var desc = new ActionDescriptor();
desc.putPath( charIDToTypeID( "null" ), tempFile );
executeAction( stringIDToTypeID( "placedLayerReplaceContents" ), desc, DialogModes.NO );
if( layerTransparency ) app.activeDocument.activeLayer.name = layerName;
tempFile.remove();
// convert back to orginal resolution
if( docRes != undefined ) app.activeDocument.resizeImage(undefined, undefined, docRes, ResampleMethod.NONE);
isCancelled = false;// no errors so save to record
} /* try block ender */
catch(e) {
if( tempFile.exists ) tempFile.remove();
/////////////////////// functions below /////////////////////////
// see if i can tell that this layer has transparent pixels
function HasLayerTransparency() {
var hasTransparency = false;
if( app.activeDocument.activeLayer.isBackgroundLayer ) return false;
try {
SelectLayerTransparency();
var s = activeDocument.selection;
if ( null != s && ! s.solid ) {
activeDocument.selection.deselect();
return true;
if ( (s[2].value - s[0].value) == activeDocument.width.value &&
(s[3].value - s[1].value) == activeDocument.height.value) {
activeDocument.selection.deselect();
return false;
activeDocument.selection.deselect();
catch(e) {
activeDocument.selection.deselect();
hasTransparency = false;
return hasTransparency;
function SelectLayerTransparency() {
if(app.activeDocument.activeLayer.isBackgroundLayer){
return -1;
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putProperty( charIDToTypeID( "Chnl" ), charIDToTypeID( "fsel" ) );
desc.putReference( charIDToTypeID( "null" ), ref );
var ref1 = new ActionReference();
ref1.putEnumerated( charIDToTypeID( "Chnl" ), charIDToTypeID( "Chnl" ), charIDToTypeID( "Trsp" ) );
desc.putReference( charIDToTypeID( "T " ), ref1 );
executeAction( charIDToTypeID( "setd" ), desc, DialogModes.NO );
try{
activeDocument.selection.bounds;
}catch(e){
return -1;
function SaveAsTIFF( inFileName ) {
var tiffSaveOptions = new TiffSaveOptions();
tiffSaveOptions.embedColorProfile = true;
tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW;
tiffSaveOptions.alphaChannels = false;
tiffSaveOptions.layers = false;
app.activeDocument.saveAs( new File( inFileName ), tiffSaveOptions, true, Extension.LOWERCASE );
// a color mode independent way to make the component channel active.
function selectComponentChannel() {
try{
var map = {};
map[DocumentMode.GRAYSCALE] = charIDToTypeID('Blck');// grayscale
map[DocumentMode.RGB] = charIDToTypeID('RGB ');
map[DocumentMode.CMYK] = charIDToTypeID('CMYK');
map[DocumentMode.LAB] = charIDToTypeID('Lab ');
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Chnl'), charIDToTypeID('Chnl'), map[app.activeDocument.mode] );
desc.putReference( charIDToTypeID('null'), ref );
executeAction( charIDToTypeID('slct'), desc, DialogModes.NO );
}catch(e){}
// function to see if there is a raster layer mask, returns true or false
function hasChannelMask(){
if( app.activeDocument.activeLayer.isBackgroundLayer ) return false;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
return executeActionGet( ref ).getBoolean( stringIDToTypeID( 'hasUserMask' ) );
// function to see if there is a vector layer mask, returns true or false
function hasVectorMask(){
if( app.activeDocument.activeLayer.isBackgroundLayer ) return false;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
return executeActionGet( ref ).getBoolean( stringIDToTypeID( 'hasVectorMask' ) );
// create an new alpha from layer channel mask, returns channel object.
function channelMaskToAlphaChannel() {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Chnl'), charIDToTypeID('Chnl'), charIDToTypeID('Msk ') );
desc.putReference( charIDToTypeID('null'), ref );
executeAction( charIDToTypeID('Dplc'), desc, DialogModes.NO );
var dupedMask = app.activeDocument.activeChannels[0];
selectComponentChannel();
return dupedMask;
function deleteChannelMask() {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Chnl'), charIDToTypeID('Chnl'), charIDToTypeID('Msk ') );
desc.putReference( charIDToTypeID('null'), ref );
executeAction( charIDToTypeID('Dlt '), desc, DialogModes.NO );
// creates a layer channel mask from a channel object
function alphaToChannelMask( alpha ) {
var desc = new ActionDescriptor();
desc.putClass( charIDToTypeID( "Nw " ), charIDToTypeID( "Chnl" ) );
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID( "Chnl" ), charIDToTypeID( "Chnl" ), charIDToTypeID( "Msk " ) );
desc.putReference( charIDToTypeID( "At " ), ref );
desc.putEnumerated( charIDToTypeID( "Usng" ), charIDToTypeID( "UsrM" ), charIDToTypeID( "RvlA" ) );
executeAction( charIDToTypeID( "Mk " ), desc, DialogModes.NO );
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Chnl'), charIDToTypeID('Chnl'), charIDToTypeID('Msk ') );
desc.putReference( charIDToTypeID('null'), ref );
desc.putBoolean( charIDToTypeID('MkVs'), false );
executeAction( charIDToTypeID('slct'), desc, DialogModes.NO );
var desc = new ActionDescriptor();
var desc1 = new ActionDescriptor();
var ref = new ActionReference();
ref.putName( charIDToTypeID('Chnl'), alpha.name );
desc1.putReference( charIDToTypeID('T '), ref );
desc1.putBoolean( charIDToTypeID('PrsT'), true );
desc.putObject( charIDToTypeID('With'), charIDToTypeID('Clcl'), desc1 );
executeAction( charIDToTypeID('AppI'), desc, DialogModes.NO );
selectComponentChannel();
function combineChannelMaskWithAplha( alpha ) {// channel object
var restore = false;
try{
app.activeDocument.activeChannels;
var restore = true;
}catch(e){}
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Chnl'), charIDToTypeID('Chnl'), charIDToTypeID('Msk ') );
desc.putReference( charIDToTypeID('null'), ref );
desc.putBoolean( charIDToTypeID('MkVs'), false );
executeAction( charIDToTypeID('slct'), desc, DialogModes.NO );
var desc = new ActionDescriptor();
var desc1 = new ActionDescriptor();
var ref = new ActionReference();
ref.putName( charIDToTypeID('Chnl'), alpha.name );
desc1.putReference( charIDToTypeID('T '), ref );
desc1.putEnumerated( charIDToTypeID('Clcl'), charIDToTypeID('Clcn'), stringIDToTypeID( "linearBurn" ) );
desc1.putDouble( charIDToTypeID('Scl '), 1.000000 );
desc1.putInteger( charIDToTypeID('Ofst'), 0 );
desc1.putBoolean( charIDToTypeID('PrsT'), true );
desc.putObject( charIDToTypeID('With'), charIDToTypeID('Clcl'), desc1 );
executeAction( charIDToTypeID('AppI'), desc, DialogModes.NO );
if( restore ) selectComponentChannel();
// creates a new alpha channel from active layer's transparency, returns channel object
function layerTransparencyToAlpha() {
var tempAlpha = app.activeDocument.channels.add();
var desc = new ActionDescriptor();
var desc1 = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Chnl'), charIDToTypeID('Chnl'), charIDToTypeID('Trsp') );
desc1.putReference( charIDToTypeID('T '), ref );
desc1.putBoolean( charIDToTypeID('PrsT'), true );
desc.putObject( charIDToTypeID('With'), charIDToTypeID('Clcl'), desc1 );
executeAction( charIDToTypeID('AppI'), desc, DialogModes.NO );
selectComponentChannel();
return tempAlpha;
// gets channel mask settings, returns custom object
function getChannelMaskSettings(){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet(ref);
var channelMask = {};
// density should be percent. it is 0-255 instead. so convert because percent is need to set
channelMask.density = Math.round((desc.getInteger( stringIDToTypeID( 'userMaskDensity' ) ) / 255)*100);
channelMask.feather = desc.getUnitDoubleValue( stringIDToTypeID( 'userMaskFeather' ) );
return channelMask;
function setChannelMaskDensity( density ) {// integer
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc.putReference( charIDToTypeID('null'), ref );
var desc1 = new ActionDescriptor();
desc1.putUnitDouble( stringIDToTypeID('userMaskDensity'), charIDToTypeID('#Prc'), density );
desc.putObject( charIDToTypeID('T '), charIDToTypeID('Lyr '), desc1 );
executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );
function setChannelMaskFeather( feather ) {// double
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc.putReference( charIDToTypeID('null'), ref );
var desc1 = new ActionDescriptor();
desc1.putUnitDouble( stringIDToTypeID('userMaskFeather'), charIDToTypeID('#Pxl'), feather );
desc.putObject( charIDToTypeID('T '), charIDToTypeID('Lyr '), desc1 );
executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );
// gets vector mask settings, returns custom object
function getVectorMaskSettings(){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet(ref);
var vectorMask = {};
vectorMask.density = Math.round((desc.getInteger( stringIDToTypeID( 'vectorMaskDensity' ) ) / 255)*100);
vectorMask.feather = desc.getUnitDoubleValue( stringIDToTypeID( 'vectorMaskFeather' ) );
return vectorMask;
function setVectorMaskDensity( density ) {// integer
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc.putReference( charIDToTypeID('null'), ref );
var desc1 = new ActionDescriptor();
desc1.putUnitDouble( stringIDToTypeID('vectorMaskDensity'), charIDToTypeID('#Prc'), density );
desc.putObject( charIDToTypeID('T '), charIDToTypeID('Lyr '), desc1 );
executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );
function setVectorMaskFeather( feather ) {// double
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc.putReference( charIDToTypeID('null'), ref );
var desc1 = new ActionDescriptor();
desc1.putUnitDouble( stringIDToTypeID('vectorMaskFeather'), charIDToTypeID('#Pxl'), feather );
desc.putObject( charIDToTypeID('T '), charIDToTypeID('Lyr '), desc1 );
executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );
// create a layer vector mask from active path
function createVectorMask() {
try{
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( charIDToTypeID('Path') );
desc.putReference( charIDToTypeID('null'), ref );
var mask = new ActionReference();
mask.putEnumerated( charIDToTypeID('Path'), charIDToTypeID('Path'), stringIDToTypeID('vectorMask') );
desc.putReference( charIDToTypeID('At '), mask );
var path = new ActionReference();
path.putEnumerated( charIDToTypeID('Path'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc.putReference( charIDToTypeID('Usng'), path );
executeAction( charIDToTypeID('Mk '), desc, DialogModes.NO );
}catch(e){ return -1; }
// converts the active layer into a tiff embedded smart object so it can be edited in ACR .
// editing in ACR requires ACR preferences to be set to edit all supported tiffs
function convertLayerToACRSmartObject(){
var doc = app.activeDocument;
var layerName = app.activeDocument.activeLayer.name;
app.activeDocument.activeLayer.name = "Raw Smart Object";
// convert selected layer to smart object
executeAction( stringIDToTypeID( "newPlacedLayer" ), undefined, DialogModes.NO );
app.activeDocument.activeLayer.name = layerName;
// edit selected smart object
executeAction( stringIDToTypeID( "placedLayerEditContents" ), new ActionDescriptor(), DialogModes.NO );
if(app.activeDocument.bitsPerChannel != BitsPerChannelType.SIXTEEN) app.activeDocument.bitsPerChannel = BitsPerChannelType.SIXTEEN;
if(app.activeDocument.mode != DocumentMode.RGB) app.activeDocument.changeMode(ChangeMode.RGB);
if( !tempFile.exists ) SaveAsTIFF( tempFile );
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
app.activeDocument = doc;
function calculations( ChannelEnum ){
var desc = new ActionDescriptor();
desc.putClass( charIDToTypeID( "Nw " ), charIDToTypeID( "Chnl" ) );
var s1Desc = new ActionDescriptor();
var idT = charIDToTypeID( "T " );
var s1Ref = new ActionReference();
s1Ref.putEnumerated( charIDToTypeID( "Chnl" ), charIDToTypeID( "Chnl" ), charIDToTypeID( ChannelEnum) );
s1Desc.putReference( idT, s1Ref );
var s2Ref = new ActionReference();
s2Ref.putEnumerated( charIDToTypeID( "Chnl" ), charIDToTypeID( "Chnl" ), charIDToTypeID( ChannelEnum ) );
s1Desc.putReference( charIDToTypeID( "Src2" ), s2Ref );
var idClcl = charIDToTypeID( "Clcl" );
desc.putObject( charIDToTypeID( "Usng" ), charIDToTypeID( "Clcl" ), s1Desc );
executeAction( charIDToTypeID( "Mk " ), desc, DialogModes.NO );
var c = app.activeDocument.activeChannels[0];
selectComponentChannel();
return c;
function applyChannel( channel ){
var desc= new ActionDescriptor();
var desc1 = new ActionDescriptor();
var ref = new ActionReference();
ref.putName( charIDToTypeID('Chnl'), channel.name );
desc1.putReference( charIDToTypeID('T '), ref );
desc1.putBoolean( charIDToTypeID('PrsT'), false );
desc.putObject( charIDToTypeID('With'), charIDToTypeID('Clcl'), desc1 );
executeAction( charIDToTypeID('AppI'), desc, DialogModes.NO );
function recoverLayerAndSave(){
try{
// copy layer to new doc
var doc = app.activeDocument;
var lyr = doc.activeLayer;
SelectLayerTransparency()
var mask = activeDocument.channels.add();
app.activeDocument.selection.store( mask );
app.activeDocument.selection.deselect();
selectComponentChannel();
mask.name = '7d358230-8855-11de-8a39-0800200c9a66_Alpha';
var desc = new ActionDescriptor();
var reference = new ActionReference();
reference.putClass( charIDToTypeID( "Dcmn" ) );
desc.putReference( charIDToTypeID( "null" ), reference );
desc.putString( charIDToTypeID( "Nm " ), app.activeDocument.activeLayer.name+" restored" );
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
desc.putReference( charIDToTypeID( "Usng" ), ref );
desc.putString( charIDToTypeID( "LyrN" ), app.activeDocument.activeLayer.name+" restored" );
executeAction( charIDToTypeID( "Mk " ), desc, DialogModes.NO );
if(app.activeDocument.mode != DocumentMode.RGB) app.activeDocument.changeMode(ChangeMode.RGB);
// save the current 100% transparent as mask
var recoveredRedChannel = calculations( "Rd " );
var recoveredGreenChannel = calculations( "Grn " );
var recoveredBlueChannel = calculations( "Bl " );
app.activeDocument.flatten();
app.activeDocument.activeChannels = [app.activeDocument.channels[0]];
applyChannel( recoveredRedChannel );
app.activeDocument.activeChannels = [app.activeDocument.channels[1]];
applyChannel( recoveredGreenChannel );
app.activeDocument.activeChannels = [app.activeDocument.channels[2]];
applyChannel( recoveredBlueChannel );
selectComponentChannel();
trimBackground();
SaveAsTIFF( tempFile );
app.activeDocument.close( SaveOptions.DONOTSAVECHANGES );
app.activeDocument = doc;
}catch(e){};
function trimBackground() {
var desc = new ActionDescriptor();
desc.putEnumerated( stringIDToTypeID('trimBasedOn'), stringIDToTypeID('trimBasedOn'), stringIDToTypeID('topLeftPixelColor') );
desc.putBoolean( charIDToTypeID('Top '), true );
desc.putBoolean( charIDToTypeID('Btom'), true );
desc.putBoolean( charIDToTypeID('Left'), true );
desc.putBoolean( charIDToTypeID('Rght'), true );
executeAction( stringIDToTypeID('trim'), desc, DialogModes.NO );
};// end EditLayersInACR() -
What I want to do is to compare 2444 polygons in table A with 8856 in table B, measuring the overlap between the polygons in A and B compared to the area of the polygons in table B.
I first use an sdo_relate with mask anyinteract to create a "short" list of 41000 candidate polygons that are connected in some way, at the same time saving the area of the table B polygon (using the sdo_area function). This first stage takes about an hour.
Then I retrieve each pair of candidate polygons and do an sdo_intersection, calculate the sdo_area of the intersection, divide by the area of polygon B and save that fraction. Problem is that it takes quite a long time to do the intersection and area calculation (almost a minute for each polygon pair) and this means it's going to take something like 28 days to complete the whole run. That's not really practical.
If anybody can suggest a better way to do this I would be very grateful.
I use the diminfo version of sdo_intersection. I am using Spatial 8.1.6 and object model.
nullHi Matthew,
I'm not sure what the exact process is.
When you compare polygons, are you only comparing the ones that have a known interaction?
If so, then you are doing the right thing, and it is probably the best way to do it.
Assuming the geometries you are comparing are fairly large, there are performance improvements in 9i that will make this run much faster (with no changes to what you are currently doing).
Sorry the new isn't better.
dan -
SDO_relate mask EQUAL giving erroneus results
I'm working in Oracle 9i attempting to test our list of maps to find duplicate maps using the SDO_RELATE with equal mask. We're trying to notice if we have any changes between one version of a map for a given territory from it's older/newer versions.
When i compare what i know to be equal maps with the above described query i get a "TRUE" response as expected. When i compare a given map to the entire table full of maps i sometimes get one extra map that says it is equal as well. When i pull up the supposedly equal map it is not at all equal but shares one common border. Its like Missouri and Illinois being called equal. According to all the documentation this should not be the result. TRUE results should be truly EQUAL. Is there any type of known bug about this in Oracle 9i or a way to make it work correctly? How equal are equal results likely to be?You should try going up to 9208 as many of these type of bugs are fixed in that
patch set.
siva -
SDO_RELATE AND SDO_GEOM RELATE MASK PROBLEMS
I am trying to use the SDO_RELATE operator on my spatial table.
I have been experiencing problems.
I also get the same problems if I use the SDO_GEOM.RELATE geometry function.
Background
Table2 contains about 20 000 rows.
Table1 contains about 1 000 000 rows.
Both tables contain area geomteries.
I can not get the following 'masks' to return any results.
-- OVERLAPBDYINTERSECT
-- COVEREDBY
-- COVERS
-- OVERLAPBDYDISJOINT
The all return -
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Elapsed: 00:00:20.00
However the mask INSIDE does work!!! And it returns the correct results.
The query syntax I am using is below. And substituting any of the above mentioned masks for INSIDE results in the ORA-03113 error.
I have validated all the geometies in my table using SDO_GEOM.VALIDATE_LAYER. They are all valid.
Query Syntax
SELECT /* ORDERED */ count(g2.parcel_ref)
FROM table2 g2
WHERE 1 < (SELECT /*+ ORDERED */ count(*)
FROM table1 g1
WHERE SDO_RELATE (g1.geometry,
g2.geom,
'MASK=INSIDE querytype=WINDOW') ='TRUE');
SELECT /* ORDERED ORDERED_PREDICATES */ count(g2.parcel_ref)
FROM table2 g2
WHERE 1 < (SELECT /*+ ORDERED */ count(*)
FROM table1 g1
WHERE SDO_FILTER (g1.geometry, g2.geom, 'querytype=WINDOW')='TRUE'
AND SDO_GEOM.RELATE (g1.geometry, 'inside', g2.geom,0.001)='INSIDE');
Does anybody have any ideas why all the masks (except INSIDE) fail?
Thanks,
BobDan,
I have finally got back to looking at my problem queries.
The first discovery I have found is that I can repeat the problem using one feature in one of the geometry tables.
You can see the syntax that I am using below. As I stated before, the INDSIDE query works, but the COVEREDBY fails.
OVERLAPBDYINTERSECT,COVEREDBY,COVERS,OVERLAPBDYDISJOINT also return the same ORA-03113 error.
SELECT /* ORDERED */ count(g2.parcel_ref)
FROM table2 g2
WHERE g2.id = 3658
AND 1 < (SELECT /*+ ORDERED */ count(*)
FROM table1 g1
WHERE SDO_RELATE (g1.geometry, g2.geom, 'MASK=INSIDE querytype=WINDOW') ='TRUE');
*** THIS ONE WORKS!
SELECT /* ORDERED */ count(g2.parcel_ref)
FROM table2 g2
WHERE g2.id = 3658
AND 1 < (SELECT /*+ ORDERED */ count(*)
FROM table1 g1
WHERE SDO_RELATE (g1.geometry, g2.geom, 'MASK=COVEREDBY querytype=WINDOW') ='TRUE');
*** THIS ONE DOES NOT WORK! The error is below.
SELECT /* ORDERED */ count(g2.parcel_ref)
ERROR at line 1:
ORA-03113: end-of-file on communication channel
I have also been running some other queries on my data.
Again, one query works, the other does not.
SELECT /*+ ORDERED ORDERED_PREDICATES */ count(*)
FROM table2 g1, table2 g2
WHERE g1.id = 194
AND SDO_FILTER (g2.geom, g1.geom, 'querytype=WINDOW')='TRUE'
AND SDO_GEOM.RELATE (g2.geom, 'overlapbdyintersect', g1.geom,0.0001)='OVERLAPBDYINTERSECT';
*** THIS ONE WORKS!
SELECT /*+ ORDERED */ count(*)
FROM table2 g1, table2 g2
WHERE g1.id = 194
AND SDO_RELATE (g2.geom, g1.geom, 'MASK=OVERLAPBDYINTERSECT querytype=WINDOW') ='TRUE';
*** THIS ONE DOES NOT WORK! Again, the error is below.
SELECT /*+ ORDERED */ count(*)
ERROR at line 1:
ORA-03113: end-of-file on communication channel
I have checked that the two problem geometries are 'valid'.
SQL> select sdo_geom.validate_geometry(geom, 0.001) from table2 where id=194;
SDO_GEOM.VALIDATE_GEOMETRY(GEOM,0.001)
TRUE
SQL> select sdo_geom.validate_geometry(geom, 0.001) from table2 where id=3658;
SDO_GEOM.VALIDATE_GEOMETRY(GEOM,0.001)
TRUE
Below is a print of the geometry of each of the problem features.
Have you got any ideas as to why the queries are failing?
Thanks in advance,
Bob
SQL> select geom from sample_lr_prm_iacs2002 where id=3658;
GEOM(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
SDO_GEOMETRY(2003, 81989, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_AR
RAY(475710.144, 133881.126, 475714.379, 133844.065, 475723.656, 133762.89, 47572
4.07, 133759.271, 475964.952, 133791.345, 475963, 133796.9, 475959, 133806.2, 47
5956.8, 133812.5, 475955.2, 133816.1, 475951.3, 133824.1, 475944.3, 133838.6, 47
5933.5, 133861.8, 475932, 133864.5, 475928.5, 133869.7, 475918.8, 133885.8, 4759
12.5, 133897, 475907.6, 133903.9, 475898.6, 133914.2, 475888.8, 133922.7, 475824
.2, 133974.3, 475809.9, 133976.2, 475808.1, 133974.6, 475805.5, 133972, 475796.3
, 133955.7, 475783.99, 133933.51, 475782.67, 133931.44, 475780.87, 133927.97, 47
5780.14, 133927, 475778.95, 133924.69, 475778.12, 133923.03, 475775.33, 133919.3
4, 475773.51, 133917.39, 475768.42, 133913.14, 475765.56, 133911.12, 475757.25,
133906.26, 475751.77, 133903.28, 475741.52, 133897.2, 475714.92, 133883.62, 4757
GEOM(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
10.86, 133881.5, 475710.144, 133881.126))
SQL> select geom from table2 where id=194;
GEOM(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
SDO_GEOMETRY(2003, 81989, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_AR
RAY(467345.544, 109699.287, 467345.379, 109699.279, 467345.288, 109698.752, 4673
44.9, 109696.5, 467339.8, 109665.2, 467325.9, 109583.1, 467311.35, 109500, 46730
9.1, 109487, 467308.27, 109482.113, 467308.242, 109482.142, 467307.491, 109478.1
99, 467307.44, 109477.435, 467307.3, 109475.9, 467307.331, 109475.837, 467307.02
4, 109471.295, 467306.963, 109471.307, 467306.831, 109471.334, 467306.831, 10946
9.765, 467307.192, 109469.68, 467310.196, 109468.973, 467345.545, 109459.288, 46
7363.626, 109453.84, 467395.576, 109447.4, 467444.616, 109440.217, 467457.247, 1
09439.474, 467460.715, 109437.245, 467461.458, 109436.255, 467467.251, 109435.39
6, 467468.145, 109435.264, 467468.264, 109435.663, 467481.7, 109435.2, 467487.2,
109435.3, 467488.8, 109435.4, 467490.6, 109435.5, 467493.4, 109435.9, 467495.6,
GEOM(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
109435.9, 467500, 109435.8, 467505.75, 109435.8, 467515.85, 109436.2, 467525.2,
109436.45, 467531.95, 109436.5, 467534.7, 109436.55, 467541.45, 109436.8, 46754
4.65, 109437.05, 467547.65, 109437.3, 467551.3, 109437.7, 467551.95, 109437.75,
467555.6, 109438.1, 467556.4, 109438.15, 467558.6, 109438.25, 467562.95, 109438.
35, 467585.5, 109439.1, 467593.55, 109439.35, 467597.5, 109439.35, 467600.45, 10
9439.3, 467603.65, 109439.35, 467606.8, 109439.3, 467607, 109439.3, 467610.15, 1
09439.2, 467613.35, 109439, 467615.7, 109438.8, 467618, 109438.55, 467620.3, 109
438.25, 467623.3, 109437.65, 467626.2, 109437.1, 467626.85, 109437, 467629.8, 10
9436.5, 467631.6, 109436.25, 467634.15, 109435.95, 467635.05, 109435.85, 467636.
95, 109435.7, 467637.35, 109435.65, 467639.25, 109435.4, 467640.1, 109435.25, 46
7641, 109435.1, 467643.7, 109434.5, 467644.3, 109434.3, 467652.15, 109432.45, 46
GEOM(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
7653.35, 109432.2, 467654.4, 109431.95, 467656.8, 109431.25, 467658.35, 109430.7
5, 467659.75, 109430.15, 467660, 109430.05, 467662.95, 109429.15, 467667.25, 109
427.9, 467667.8, 109427.8, 467668.5, 109427.7, 467670, 109427.5, 467670.7, 10942
7.4, 467671.45, 109427.35, 467671.7, 109427.35, 467678.95, 109427.45, 467680.4,
109427.5, 467681.75, 109427.55, 467683.2, 109427.55, 467684.55, 109427.5, 467685
.95, 109427.45, 467687.35, 109427.35, 467688.55, 109427.25, 467695.4, 109426.55,
467696.8, 109426.45, 467698.15, 109426.3, 467699.55, 109426.1, 467700.75, 10942
5.95, 467703.45, 109425.35, 467703.95, 109425.2, 467708.85, 109423.95, 467717.8,
109421.4, 467721.2, 109420.5, 467726.4, 109419.2, 467729.8, 109418.5, 467731.45
, 109418.15, 467735.95, 109417.45, 467737.5, 109417.25, 467742.8, 109417.05, 467
748.2, 109416.7, 467748.95, 109416.6, 467749.7, 109416.45, 467750.5, 109416.3, 4
GEOM(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
67752, 109415.9, 467752.75, 109415.65, 467753.4, 109415.45, 467753.95, 109415.2,
467754.55, 109415, 467755.1, 109414.75, 467755.6, 109414.45, 467756.15, 109414.
2, 467756.45, 109414, 467762.25, 109409.8, 467768.8, 109404.9, 467770.4, 109403.
7, 467771.3, 109403.1, 467771.513, 109402.932, 467772.658, 109403.214, 467772.92
9, 109403.281, 467777.496, 109404.803, 467790.963, 109405.789, 467804.758, 10940
7.103, 467810.013, 109407.431, 467821.181, 109409.73, 467831.035, 109410.716, 46
7843.188, 109412.03, 467849.757, 109412.686, 467853.992, 109414.38, 467854.15, 1
09416.85, 467854.85, 109427.6, 467855.35, 109436.3, 467855.75, 109443.95, 467856
.25, 109451.7, 467854.7, 109460.35, 467852.45, 109472, 467850.5, 109482.45, 4678
48.45, 109493.25, 467847.15, 109500, 467846.25, 109505.2, 467845, 109511.7, 4678
44.25, 109515.9, 467843.15, 109521.5, 467841.85, 109528.55, 467840.65, 109534.95
GEOM(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
, 467840.05, 109538.2, 467839.65, 109542.4, 467839.05, 109548.35, 467838.55, 109
553.6, 467837.9, 109560.6, 467837.2, 109568, 467836.45, 109576.3, 467836.05, 109
581.45, 467835.45, 109588.4, 467834.55, 109597.9, 467833.1, 109614.5, 467832.35,
109622, 467831.2, 109634.4, 467830.6, 109640.2, 467830.55, 109640.5, 467828.5,
109642.15, 467824.2, 109642.3, 467821.1, 109642.35, 467819.75, 109642.4, 467818.
9, 109642.4, 467818.6, 109642.45, 467818.4, 109642.45, 467818.25, 109642.5, 4678
18.05, 109642.5, 467817.85, 109642.55, 467817.65, 109642.5, 467817.45, 109642.5,
467817.2, 109642.55, 467816.95, 109642.55, 467816.7, 109642.6, 467816.45, 10964
2.6, 467815.85, 109642.7, 467815.35, 109642.7, 467814.65, 109642.8, 467812.25, 1
09643.05, 467811.4, 109643.1, 467810.55, 109643.2, 467809.1, 109643.4, 467807.1,
109643.7, 467805.75, 109643.85, 467804.45, 109643.95, 467800.55, 109644.5, 4677
GEOM(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
98.75, 109644.7, 467795.9, 109645, 467794.95, 109645.15, 467793.6, 109645.3, 467
792.15, 109645.55, 467790.65, 109645.75, 467787.25, 109646.05, 467782.8, 109646.
5, 467778.15, 109646.95, 467774.5, 109647.4, 467770.1, 109647.85, 467765.75, 109
648.3, 467760.85, 109648.9, 467753.35, 109649.65, 467748.7, 109650.1, 467745.15,
109650.45, 467741.05, 109650.85, 467739.95, 109650.95, 467736.45, 109651.35, 46
7732.1, 109651.95, 467729.1, 109652.3, 467724.95, 109652.7, 467723.05, 109652.95
, 467720.5, 109653.2, 467716.65, 109653.75, 467712.05, 109654.45, 467708.65, 109
654.9, 467704.45, 109655.4, 467700.35, 109655.95, 467695.65, 109656.65, 467692.4
, 109657.1, 467690.4, 109657.25, 467682.65, 109657.8, 467679, 109658.1, 467676.1
5, 109658.35, 467674.75, 109658.5, 467674.3, 109658.5, 467674.1, 109658.55, 4676
73.7, 109658.55, 467673.3, 109658.65, 467673, 109658.7, 467672.7, 109658.8, 4676
GEOM(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
72.1, 109658.9, 467671.4, 109659, 467670.9, 109659.1, 467670, 109659.25, 467669.
75, 109659.3, 467668.75, 109659.4, 467668.3, 109659.4, 467667.85, 109659.45, 467
665.4, 109659.65, 467661.9, 109660.05, 467659.5, 109660.3, 467656.65, 109660.7,
467652.55, 109661.25, 467648.35, 109661.8, 467644.65, 109662.25, 467641.7, 10966
2.65, 467639.5, 109662.9, 467636.75, 109663.25, 467633.25, 109663.6, 467631.7, 1
09663.75, 467631.5, 109663.8, 467631.1, 109663.8, 467630.9, 109663.85, 467630.55
, 109663.85, 467630.35, 109663.9, 467630.2, 109663.95, 467629.85, 109663.95, 467
629.05, 109664.05, 467628.35, 109664.15, 467628.05, 109664.2, 467627.7, 109664.3
, 467625.95, 109664.55, 467623.15, 109665.1, 467622.85, 109665.15, 467622.6, 109
665.25, 467622.3, 109665.3, 467622.05, 109665.35, 467621.9, 109665.35, 467621.65
, 109665.4, 467621.4, 109665.4, 467621.15, 109665.45, 467620.95, 109665.5, 46762
GEOM(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
0.7, 109665.6, 467620.5, 109665.65, 467620.3, 109665.65, 467619.8, 109665.75, 46
7619.5, 109665.8, 467619.15, 109665.8, 467618.45, 109665.9, 467616.8, 109666.1,
467613.2, 109666.6, 467610.15, 109667.05, 467608, 109667.3, 467605.85, 109667.5,
467603.75, 109667.7, 467602.25, 109667.9, 467601.05, 109668, 467597.05, 109668.
35, 467592.6, 109668.8, 467589.7, 109669.1, 467587.1, 109669.4, 467583.65, 10966
9.75, 467580.7, 109670.1, 467576.3, 109670.65, 467567, 109671.85, 467562.25, 109
672.4, 467556.85, 109673, 467553.95, 109673.3, 467550.35, 109671.95, 467545.1, 1
09670, 467540.35, 109668.3, 467539.9, 109668.15, 467539.75, 109668.15, 467539.6,
109668.1, 467539.5, 109668.05, 467539.35, 109668, 467539.2, 109668, 467539, 109
667.95, 467538.75, 109667.95, 467538.55, 109667.9, 467538.35, 109667.9, 467534.8
, 109667.7, 467530.65, 109667.35, 467523.9, 109666.75, 467519.5, 109666.4, 46751
GEOM(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
6.2, 109666.1, 467511.8, 109665.65, 467508.1, 109665.3, 467504.85, 109664.9, 467
501.35, 109664.5, 467500, 109664.4, 467498.7, 109664.3, 467480.5, 109673.4, 4674
73.7, 109677, 467468.4, 109680, 467461.5, 109683.8, 467453.2, 109688.1, 467448.1
, 109690.4, 467441.4, 109693, 467439.6, 109693.6, 467430, 109696.2, 467424, 1096
97.7, 467420.3, 109698.5, 467419.444, 109698.653, 467419.409, 109698.708, 467397
.983, 109702.395, 467373.562, 109709.767, 467362.964, 109719.213, 467362.94, 109
718.668, 467362.504, 109719.213, 467347.528, 109705.39, 467346.459, 109701.945,
467346.01, 109700.498, 467345.636, 109699.291, 467345.544, 109699.287)) -
Hi:
I know how to use a single key mask with an alpha-key to produce a shortcut key (eg ctrl+N).
But How would I combine 2 key masks such as ctrl and shift so that you can press those 2 keys with another normal alpha-key to produce a shortcut key?
Please help...
thanks!My guess would be to 'or' them together
multimask = MASK_SHIFT | MASK_CTRL;
But without knowing what you are trying to do, it's just a guess. -
Combining a path motion tween with a mask
I have a mask layer that I have animated and underneath that
I have a motion tween of a symbol using a path motion guide. The
mask doesn't seem to work with those layers. Is that a restriction?
If so BIG BIG BUMMER!!create a black shape in your bottom-most layer. above that layer create a while shape that covers you black shape. above that layer create your oval and tween it. finally right click the oval containing layer and click mask. test.
-
Not using Index when SDO_RELATE in Spatial Query is used in LEFT OUTER JOIN
I want to know for every City (Point geometry) in which Municipality (Polygon geometry) it is.
Some cities will not be covered by any municipality (as there is no data for it), so its municipality name should be blank in the result
We have 4942 cities (point geometries)
and 500 municipalities (polygon geometry)
SELECT T1.NAME as City, T2.NAME as Municipality
FROM CITY T1
LEFT OUTER JOIN MUNICIPALITY T2 ON SDO_RELATE(T1.GEOM, T2.GEOM, 'MASK=ANYINTERACT') = 'TRUE'The explain plan for this query is:
SELECT STATEMENT
FILTER
Filter Predicates
MDSYS.SDO_RTREE_RELATE(T1.GEOM, T2.GEOM, 'mask=ANYINTERACT querytype=window ') = 'TRUE'
MERGE JOIN
TABLE ACCESS CITY FULL 11
BUFFER SORT 100605
TABLE ACCESS MUNICIPALITY FULL 20So the cost is in the BUFFER (whatever that is), it takes +2000 seconds to run this, it is not using the spatial index.
And we are not getting all rows, but only the ones interacting with a municipality, e.g. 2436 rows.
But I want all rows, including the ones not interacting with any Municipality.
When we want only those cities that actually are in a municipality, I use a different query and it will use the index.
SELECT T1.NAME as City, T2.NAME as Municipality
FROM CITY T1, MUNICIPALITY T2
WHERE SDO_RELATE(T1.GEOM, T2.GEOM, 'MASK=ANYINTERACT') = 'TRUE'I get (only) 2436 rows (as expected) in 5 seconds (it is fast) and the explain plan shows it is using the spatial index.
But in this case, I am not getting any cities not inside any municipality (of course)
SELECT STATEMENT
NESTED LOOPS
TABLE ACCESS MUNICIPALITY FULL 22
TABLE ACCESS CITY BY INDEX ROWID 22
DOMAIN INDEX CITY_SDX 0
Access Predicates
MDSYS.SDO_RTREE_RELATE(T1.GEOM, T2.GEOM, 'mask=ANYINTERACT querytype=window ') = 'TRUE'I always thought a LEFT OUTER JOIN would return all rows from the Table, whatever happens in the next,
but it seems the query has been rewritten so that it is now using a Filter Predicate in the end, which filters those geometries having no interaction.
As an example I also do thing alphanumerically, I do get 4942 rows, including the ones which have no Municipality name.
In this case the names must match, so its only for testing if the LEFT OUTER JOIN returns stuff correctly, which it does in this case.
SELECT T1.NAME as City, T2.NAME as Municipality
FROM CITY T1
LEFT OUTER JOIN MUNICIPALITY T2 ON T1.NAME = T2.NAMEIs this an Oracle Spatial bug, e.g. not return 4942 rows, but only 2436 rows on the first query?
Note all tests performed on Oracle 11g R2 (11.2.0.1.0)Patrick,
Even so, your geoms in the relate were the wrong way around.
Also, I don't recall you saying (or showing) that you wanted the municipality geometry returned. Still,
no matter, easy to do.
Here are some additional suggestions. I don't have your data so I have had to use some of my own.
set serveroutput on timing on autotrace on
SELECT T1.SPECIES as City,
(SELECT T2.ADMIN_NAME FROM AUSTRALIAN_STATES T2 WHERE SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE') as Municipality,
(SELECT T2.GEOM FROM AUSTRALIAN_STATES T2 WHERE SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE') as geom
FROM GUTDATA T1;
762 rows selected
Elapsed: 00:00:21.656
Plan hash value: 2160035213
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 762 | 49530 | 5 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| AUSTRALIAN_STATES | 1 | 115 | 0 (0)| 00:00:01 |
|* 2 | DOMAIN INDEX | AUSTRALIAN_STATES_GEOM_SPX | | | 0 (0)| 00:00:01 |
| 3 | TABLE ACCESS BY INDEX ROWID| AUSTRALIAN_STATES | 1 | 115 | 0 (0)| 00:00:01 |
|* 4 | DOMAIN INDEX | AUSTRALIAN_STATES_GEOM_SPX | | | 0 (0)| 00:00:01 |
| 5 | TABLE ACCESS FULL | GUTDATA | 762 | 49530 | 5 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"(:B1,10000,0.5,'UNIT=M'))='TRUE')
4 - access("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"(:B1,10000,0.5,'UNIT=M'))='TRUE')
Statistics
7 user calls
24576 physical read total bytes
0 physical write total bytes
0 spare statistic 3
0 commit cleanout failures: cannot pin
0 TBS Extension: bytes extended
0 total number of times SMON posted
0 SMON posted for undo segment recovery
0 SMON posted for dropping temp segment
0 segment prealloc tasksThe above can look messy as you add more (SELECT ...) attributes, but is is fast (though can't use in Materialized Views).
/* The set of all cities not in municipalities */
SELECT T1.SPECIES as City,
cast(null as varchar2(42)) as municipality,
cast(null as sdo_geometry) as geom
FROM GUTDATA T1
WHERE NOT EXISTS (SELECT 1
FROM AUSTRALIAN_STATES T2
WHERE SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE')
UNION ALL
/* The set of all cities in municipalities */
SELECT T1.SPECIES as City,
T2.ADMIN_NAME as Municipality,
T2.GEOM as geom
FROM GUTDATA T1
INNER JOIN
AUSTRALIAN_STATES T2 ON (SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE');
762 rows selected
Elapsed: 00:00:59.953
Plan hash value: 2854682795
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 99 | 13450 | 38 (87)| 00:00:01 |
| 1 | UNION-ALL | | | | | |
|* 2 | FILTER | | | | | |
| 3 | TABLE ACCESS FULL| GUTDATA | 762 | 49530 | 5 (0)| 00:00:01 |
|* 4 | DOMAIN INDEX | AUSTRALIAN_STATES_GEOM_SPX | | | 0 (0)| 00:00:01 |
| 5 | NESTED LOOPS | | 61 | 10980 | 33 (0)| 00:00:01 |
| 6 | TABLE ACCESS FULL| AUSTRALIAN_STATES | 8 | 920 | 3 (0)| 00:00:01 |
|* 7 | TABLE ACCESS FULL| GUTDATA | 8 | 520 | 4 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter( NOT EXISTS (SELECT 0 FROM "AUSTRALIAN_STATES" "T2" WHERE "MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"(:B1,10000,0.5,'UNIT=M'))='TRUE'))
4 - access("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"(:B1,10000,0.5,'UNIT=M'))='TRUE')
7 - filter("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"("T1"."GEOM",10000,0.5,'UNIT=M'))='TRUE')
Statistics
7 user calls
131072 physical read total bytes
0 physical write total bytes
0 spare statistic 3
0 commit cleanout failures: cannot pin
0 TBS Extension: bytes extended
0 total number of times SMON posted
0 SMON posted for undo segment recovery
0 SMON posted for dropping temp segment
0 segment prealloc tasksMuch slower but Materialized View friendly.
This one is a bit more "natural" but still slower than the first.
set serveroutput on timing on autotrace on
/* The set of all cities in municipalities */
WITH municipal_cities As (
SELECT T1.ID as City,
T2.ADMIN_NAME as Municipality,
T2.GEOM as geom
FROM GUTDATA T1
INNER JOIN
AUSTRALIAN_STATES T2 ON (SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE')
SELECT T1.ID as City,
T2.Municipality as Municipality,
T2.GEOM as geom
FROM GUTDATA T1
LEFT OUTER JOIN
municipal_cities T2
ON (T2.CITY = T1.ID);
762 rows selected
Elapsed: 00:00:50.228
Plan hash value: 745978991
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 762 | 44196 | 36 (3)| 00:00:01 |
|* 1 | HASH JOIN RIGHT OUTER| | 762 | 44196 | 36 (3)| 00:00:01 |
| 2 | VIEW | | 61 | 3294 | 33 (0)| 00:00:01 |
| 3 | NESTED LOOPS | | 61 | 10980 | 33 (0)| 00:00:01 |
| 4 | TABLE ACCESS FULL | AUSTRALIAN_STATES | 8 | 920 | 3 (0)| 00:00:01 |
|* 5 | TABLE ACCESS FULL | GUTDATA | 8 | 520 | 4 (0)| 00:00:01 |
| 6 | INDEX FAST FULL SCAN| GUTDATA_ID_PK | 762 | 3048 | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - access("T2"."CITY"(+)="T1"."ID")
5 - filter("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"("T1"."GEOM",10000,0.5,'UNIT=M'))='TRUE')
Statistics
7 user calls
49152 physical read total bytes
0 physical write total bytes
0 spare statistic 3
0 commit cleanout failures: cannot pin
0 TBS Extension: bytes extended
0 total number of times SMON posted
0 SMON posted for undo segment recovery
0 SMON posted for dropping temp segment
0 segment prealloc tasksFinally, the Pièce de résistance: trick the LEFT OUTER JOIN operator...
set serveroutput on timing on autotrace on
SELECT T1.SPECIES as City,
T2.ADMIN_NAME as Municipality,
T2.GEOM as geom
FROM GUTDATA T1
LEFT OUTER JOIN
AUSTRALIAN_STATES T2
ON (t2.admin_name = to_char(t1.ID) OR
SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE');
762 rows selected
Elapsed: 00:00:50.273
Plan hash value: 158854308
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 762 | 92964 | 2294 (1)| 00:00:28 |
| 1 | NESTED LOOPS OUTER | | 762 | 92964 | 2294 (1)| 00:00:28 |
| 2 | TABLE ACCESS FULL | GUTDATA | 762 | 49530 | 5 (0)| 00:00:01 |
| 3 | VIEW | | 1 | 57 | 3 (0)| 00:00:01 |
|* 4 | TABLE ACCESS FULL| AUSTRALIAN_STATES | 1 | 115 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
4 - filter("T2"."ADMIN_NAME"=TO_CHAR("T1"."ID") OR
"MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"("T1"."GEOM",10000,0.5,'UNIT=M'))='TRUE')
Statistics
7 user calls
0 physical read total bytes
0 physical write total bytes
0 spare statistic 3
0 commit cleanout failures: cannot pin
0 TBS Extension: bytes extended
0 total number of times SMON posted
0 SMON posted for undo segment recovery
0 SMON posted for dropping temp segment
0 segment prealloc tasksTry these combinations to see what works for you.
Interestingly, for me, the following returns absolutely nothing.
SELECT T1.SPECIES as City,
T2.ADMIN_NAME as Municipality
FROM GUTDATA T1
LEFT OUTER JOIN
AUSTRALIAN_STATES T2
ON (SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE')
MINUS
SELECT T1.SPECIES as City,
T2.ADMIN_NAME as Municipality
FROM GUTDATA T1
LEFT OUTER JOIN
AUSTRALIAN_STATES T2
ON (t2.admin_name = to_char(t1.ID) OR
SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE');(I leave it to you to see if you can see why as the LEFT OUTER JOIN seems to be working correctly for me but I am not going to dedicate time to detailed checking of results.)
Note all tests performed on Oracle 11g R2 (11.2.0.1.0)
If you get the answer you want: mark the post as answered to assign points.
regards
Simon
Maybe you are looking for
-
Argh! Trying to Replace Linksys with New Airport Extreme...
Been fighting with this for hours...about ready to take the new Airport Extreme back ...Here's the deal: I currently have a very wired and wireless 2story home professinally set up with 2 Linksys devices as the primary network and a couple previous g
-
Database Access VS DataStructure in Memory
Hi Everyone, I'm very new to this forum. Just started working in JSP. I'm working on a small internal project at my work, I'm presently working in the user management part of it. Basically a mysql table containing username,password etc... Now I have
-
Hardware to connect a 1st gen iPod to iMac?
I just dug up our old iPod 10-gig (2002-ish) for my kid to play with. The cable looks like like FireWire connectors on both ends. One end I plug into the power adapter the other end goes into the iPod. So far so good. Now I need to connect the thing
-
Hi Gurus, I have a interesting problem.There is a Z table ( transparent ).Lets say ZDUMMY_TABLE.When i try to see the data in ZDUMMY_TABLE from se16 i get an error like "No database table exists for table ZDUMMY_TABLE" . On the other hand there is a
-
Changing a website through iweb
i have started using iweb today and published a website. then i made some changes and published those, but the original website keeps coming up and none of the changes I've made appear to be published. i can see all the changes, and the website as I