POST
|
You should be calling graphicsContainer.next somewhere in your code. Or take out this line: graphicsContainer.Reset(); No difference. I'm not retrieving anything from the graphics container anyway, just adding elements.
... View more
11-17-2013
01:51 PM
|
0
|
0
|
348
|
POST
|
Doesn't partial refresh need to be called twice, once before and once after an "action" ? I'm not sure if that would solve your problem, but it's just something that caught my eye (though I could be mistaken). Thanks, tried that but it didn't seem to make any difference. Does it need to be the same type of partial refresh i.e. esriViewDrawPhase.esriViewGraphics?
... View more
11-14-2013
01:53 PM
|
0
|
0
|
348
|
POST
|
I'm having an issue with our ArcObjects code for exporting a map to PDF. There is a section of code that adds graphics on to the map (polygons, lines, text etc). This seems to work fine for the first map generated after the map service is started, but on subsequent prints the markup does not get displayed on the map. This code worked previously but no we've converted it to run as an SOE on ArcGIS Server. The code in question:
// IMap map, IGraphicElements graphicElements
GraphicUtil.GetGraphicsContainer(map).DeleteAllElements(); // clear any previous markup
_logger.Debug("Add graphic elements to container");
IGraphicsContainer graphicsContainer = GetGraphicsContainer(map);
graphicsContainer.Reset();
for (int i = 0; i < graphicElements.Count; i++)
{
IElement element = graphicElements.get_Element(i) as IElement;
_logger.Debug("Adding geometry type: " + element.Geometry.GeometryType.ToString());
graphicsContainer.AddElement(element, 0);
}
((IActiveView)map).PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
...
public static IGraphicsContainer GetGraphicsContainer(IMap map)
{
return (IGraphicsContainer)map;
}
If I take out the DeleteAllElements the markup stays on the map between requests but any new markup doesn't get added. If I restart the map service, then it will add the markup on the next request, then not add anything after that. In the ArcGIS Server logs I can see the following items which indicates nothing is being drawn, even though the graphic elements have been correctly added to the graphics container in the code (as far as I can tell) INFO3 End of the graphics drawing.
INFO3 Graphic count: 0.
INFO3 Beginning of the graphics drawing. Any ideas? thanks, Rowan
... View more
11-11-2013
05:51 PM
|
0
|
4
|
2205
|
POST
|
From the API doco for the createFeatureClass method in the IFeatureDataset interface "requires that the spatial reference specified for the feature class to be created match the spatial reference of the feature dataset. Note that the spatial reference for the feature class to be created is specified in the GeometryDef property of the Field object for the Shape field in the supplied Fields collection. The GeometryDef object must be fully set up with information on both the spatial reference (the projected or geographic coordinate system, vertical coordinate system, the coordinate domains and the coordinate resolution values), and the spatial index for the shape Field before calling CreateFeatureClass." My code - which was cobbled together from various sources - included a comment (removed from the snippet to reduce the number of characters) which contradicted the documentation. Unfortunately, I haven't been able to track down the offending source.
... View more
11-02-2010
03:23 PM
|
0
|
0
|
479
|
POST
|
I have been given the task of creating a file geodatabase, as a way of exporting spatial data from our (Oracle) database into a format suitable for use in a client's ArcGIS system. I have managed to create a feature workspace, and a feature dataset within this workspace. My code fails while attempting to create a feature class, throwing "AutomationException: No spatial reference exists." on the "featureDataset.createFeatureClass" call marked in the code below. I'm totally confused by this, as I have explicitly created a SpatialReference object and used it when creating the dataset. Where am I going wrong?
package envirosys.gi;
import com.esri.arcgis.datasourcesGDB.FileGDBWorkspaceFactory;
import com.esri.arcgis.geodatabase.*;
import com.esri.arcgis.geometry.*;
import com.esri.arcgis.interop.AutomationException;
import com.esri.arcgis.system.*;
import envirosys.util.*;
import oracle.jbo.*;
import org.apache.log4j.Logger;
public class GeodatabaseTask extends Thread {
private ApplicationModule am = null;
private Logger logger = null;
private String path = null;
private String filename = null;
private boolean isNew = false;
public GeodatabaseTask(ApplicationModule am, Logger logger, String path, String filename) {
this.am = am;
this.logger = logger;
this.path = path;
this.filename = filename;
}
public void run() {
try {
this.logger.info("Starting Geodatabase export");
EngineInitializer.initializeEngine();
AoInitialize aoInitializer = new AoInitialize();
if ( aoInitializer.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeArcView) == esriLicenseStatus.esriLicenseAvailable ) {
aoInitializer.initialize(esriLicenseProductCode.esriLicenseProductCodeArcView);
} else {
aoInitializer.initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);
}
IWorkspace workspace = this.getWorkspace();
IFeatureWorkspace featureWorkspace = new IFeatureWorkspaceProxy(workspace);
ISpatialReference spatialReference = new UnknownCoordinateSystem();
spatialReference.setDomain(0, 21474.83645, 0, 21474.83645);
spatialReference.setFalseOriginAndUnits(0, 0, 100000);
spatialReference.setMDomain(0, 21474.83645);
spatialReference.setZDomain(0, 21474.83645);
spatialReference.setZFalseOriginAndUnits(0, 100000);
StringBuffer sbSQL = new StringBuffer("SELECT spae_id, schema_name, table_name FROM spatial_extracts ORDER BY spae_id");
ViewObject voSpatialExtracts = DBCommon.getViewObject(this.am, "voSpatialExtracts", sbSQL.toString(), true);
while ( voSpatialExtracts.hasNext() ) {
Row rowSpatialExtract = voSpatialExtracts.next();
String spaeId = PageFields.getStringValue(rowSpatialExtract.getAttribute("SPAE_ID"));
String schemaName = PageFields.getStringValue(rowSpatialExtract.getAttribute("SCHEMA_NAME"));
String tableName = PageFields.getStringValue(rowSpatialExtract.getAttribute("TABLE_NAME"));
IFeatureDataset featureDataset = null;
if ( this.isNew ) {
featureDataset = featureWorkspace.createFeatureDataset(tableName, spatialReference);
} else {
featureDataset = featureWorkspace.openFeatureDataset(tableName);
}
IFeatureClass featureClass = this.createFeatureClass(featureDataset, spaeId, tableName);
this.createFeatures(featureClass, schemaName, tableName);
}
voSpatialExtracts.remove();
voSpatialExtracts = null;
aoInitializer.shutdown();
this.logger.info("Completed Geodatabase export");
} catch ( AutomationException ae ) {
System.out.println("CODE [" + ae.getCode() + "], DESCRIPTION [" + ae.getDescription() + "]");
} catch ( Exception e ) {
Utilities.dumpError("GeodatabaseTask.run", this.logger, e);
}
}
private IWorkspace getWorkspace() {
IWorkspace workspace = null;
try {
IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactory();
if ( workspaceFactory.isWorkspace(this.path + this.filename + ".gdb") ) {
workspace = workspaceFactory.openFromFile(this.path + this.filename + ".gdb", 0);
} else {
IWorkspaceName workspaceName = workspaceFactory.create(this.path, this.filename + ".gdb", null, 0);
IName name = (IName)workspaceName;
workspace = new IWorkspaceProxy(name.open());
this.isNew = true;
}
} catch ( AutomationException ae ) {
System.out.println("CODE [" + ae.getCode() + "], DESCRIPTION [" + ae.getDescription() + "]");
} catch ( Exception e ) {
Utilities.dumpError("GeodatabaseTask.getWorkspace", this.logger, e);
} finally {
return workspace;
}
}
private IFeatureClass createFeatureClass(IFeatureDataset featureDataset, String spaeId, String table) {
IFeatureClass featureClass = null;
try {
StringBuffer sbSQL = new StringBuffer("SELECT spae.method_alias, tesm.name FROM spatial_extract_methods spae, test_methods tesm WHERE spae.spae_id = " + spaeId + " AND tesm.tesm_id = spae.tesm_id");
ViewObject voMethods = DBCommon.getViewObject(this.am, "voMethods", sbSQL.toString(), true);
int fieldCount = new Long(voMethods.getEstimatedRowCount()).intValue() + 2;
int fieldCtr = 0;
IFields fields = new Fields();
IFieldsEdit fieldsEdit = (IFieldsEdit)fields;
fieldsEdit.setFieldCount(fieldCount);
IField fieldUserDefined = new Field();
IFieldEdit fieldEdit = (IFieldEdit)fieldUserDefined;
fieldEdit.setName("OBJECTID");
fieldEdit.setAliasName("OBJECT ID");
fieldEdit.setType(esriFieldType.esriFieldTypeOID);
fieldsEdit.setFieldByRef(fieldCtr++, fieldUserDefined);
IGeometryDef geometryDef = new GeometryDef();
IGeometryDefEdit geometryDefEdit = (IGeometryDefEdit)geometryDef;
geometryDefEdit.setGeometryType(esriGeometryType.esriGeometryPoint);
geometryDefEdit.setGridCount(1);
geometryDefEdit.setGridSize(0, 0);
geometryDefEdit.setHasM(false);
geometryDefEdit.setHasZ(false);
fieldUserDefined = new Field();
fieldEdit = (IFieldEdit)fieldUserDefined;
fieldEdit.setName("SHAPE");
fieldEdit.setType(esriFieldType.esriFieldTypeGeometry);
fieldEdit.setGeometryDefByRef(geometryDef);
fieldEdit.setIsNullable(true);
fieldEdit.setRequired(true);
fieldsEdit.setFieldByRef(fieldCtr++, fieldUserDefined);
while ( voMethods.hasNext() ) {
Row rowMethod = voMethods.next();
fieldUserDefined = new Field();
fieldEdit = (IFieldEdit)fieldUserDefined;
fieldEdit.setName(PageFields.getStringValue(rowMethod.getAttribute("NAME")));
fieldEdit.setAliasName(PageFields.getStringValue(rowMethod.getAttribute("METHOD_ALIAS")));
fieldEdit.setEditable(true);
fieldEdit.setIsNullable(false);
fieldEdit.setPrecision(18);
fieldEdit.setScale(8);
fieldEdit.setType(esriFieldType.esriFieldTypeDouble);
fieldsEdit.setFieldByRef(fieldCtr++, fieldUserDefined);
}
voMethods.remove();
voMethods = null;
IFeatureClassDescription fcDesc = new FeatureClassDescription();
IObjectClassDescription ocDesc = (IObjectClassDescription)fcDesc;
featureClass = featureDataset.createFeatureClass(table, fields, ocDesc.getInstanceCLSID(), ocDesc.getClassExtensionCLSID(), esriFeatureType.esriFTSimple, "SHAPE", ""); // fails on this line
} catch ( AutomationException ae ) {
System.out.println("CODE [" + ae.getCode() + "], DESCRIPTION [" + ae.getDescription() + "]");
} catch ( Exception e ) {
Utilities.dumpError("GeodatabaseTask.createFeatureClass", this.logger, e);
} finally {
return featureClass;
}
}
private void createFeatures(IFeatureClass featureClass, String schema, String table) {
try {
if ( featureClass.getShapeType() != esriGeometryType.esriGeometryPoint) {
return;
}
IFields fields = featureClass.getFields();
StringBuffer sbSQL = new StringBuffer("SELECT * FROM " + schema + "." + table);
ViewObject voPoints = DBCommon.getViewObject(this.am, "voPoints", sbSQL.toString(), true);
while ( voPoints.hasNext() ) {
Row rowPoint = voPoints.next();
IPoint point = null;
IFeature feature = featureClass.createFeature();
feature.setShapeByRef(point);
ISubtypes subtypes = (ISubtypes)featureClass;
IRowSubtypes rowSubtypes = (IRowSubtypes)feature;
if ( subtypes.isHasSubtype() ) {
rowSubtypes.setSubtypeCode(3);
}
rowSubtypes.initDefaultValues();
for ( int fieldCtr = 0; fieldCtr < fields.getFieldCount(); fieldCtr++ ) {
IField field = fields.getField(fieldCtr);
String alias = field.getAliasName();
String value = PageFields.getStringValue(rowPoint.getAttribute(alias));
if ( !value.equals("") ) {
feature.setValue(fieldCtr, value);
}
}
feature.store();
}
voPoints.remove();
voPoints = null;
} catch ( AutomationException ae ) {
System.out.println("CODE [" + ae.getCode() + "], DESCRIPTION [" + ae.getDescription() + "]");
} catch ( Exception e ) {
Utilities.dumpError("GeodatabaseTask.createFeatures", this.logger, e);
}
}
}
... View more
10-28-2010
06:31 PM
|
0
|
3
|
3070
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|