com.esri.adf.web.ags.data.edit.util
Class EditUtil

java.lang.Object
  extended by com.esri.adf.web.ags.data.edit.util.EditUtil

public class EditUtil
extends java.lang.Object

A helper class for ArcObject related functions.


Field Summary
static java.lang.String NOT_VERSIONED
           
 
Constructor Summary
EditUtil()
           
 
Method Summary
static com.esri.arcgis.geometry.IGeometry addVertex(double searchDistance, com.esri.arcgis.geometry.IGeometry geom, com.esri.arcgis.geometry.IPoint point, com.esri.arcgis.server.IServerContext ctx)
          Adds a vertex the geometry if it is in the search distance.
static com.esri.arcgis.geodatabase.IFeature copyFeature(com.esri.arcgis.carto.IFeatureLayer targetLayer, com.esri.arcgis.geometry.ILine offset, com.esri.arcgis.geodatabase.IFeature source)
          Copies the feature to the target layer and move it with the given offset.
static com.esri.arcgis.geodatabase.IFeature createFeature(com.esri.arcgis.carto.IFeatureLayer editLayer, com.esri.arcgis.geometry.IGeometry geom)
          Creates a geometry to a feature layer.
static java.util.Map<java.lang.Integer,Attribute> getAttributes(com.esri.arcgis.carto.IFeatureLayer fLayer, com.esri.arcgis.geodatabase.IFeature feature, AttributeFilter filter, java.text.DateFormat dateFormat)
          Gets all the editable attributes on the feature.
static java.util.Map<java.lang.Integer,com.esri.arcgis.carto.IFeatureLayer> getFeatureLayers(com.esri.arcgis.carto.IMap map, com.esri.arcgis.server.IServerContext ctx)
          Gets all feature layers from the IMap.
static com.esri.arcgis.geodatabase.IFeatureCursor getFeatures(com.esri.arcgis.carto.IFeatureLayer editLayer, int[] oids, com.esri.arcgis.server.IServerContext ctx)
          Gets the features by the given object IDs.
static com.esri.arcgis.geodatabase.IFeatureCursor getSelection(com.esri.arcgis.carto.IFeatureLayer editLayer, com.esri.arcgisws.LayerDescription ldesc, com.esri.arcgis.geometry.IGeometry geometry, com.esri.arcgis.server.IServerContext ctx)
          Gets the selected feature on the given layer intersected with the given geometry
static com.esri.arcgis.geodatabase.IFeatureCursor getSelection(com.esri.arcgis.carto.IFeatureLayer editLayer, com.esri.arcgisws.LayerDescription ldesc, com.esri.arcgis.server.IServerContext ctx)
          Gets the selected feature on the given layer.
static com.esri.arcgis.geometry.ISpatialReference getSpatialReference(com.esri.arcgis.carto.IFeatureLayer flayer)
          Gets spatial reference from a feature layer.
static java.util.List<java.lang.String> getVersions(com.esri.arcgis.carto.IMap map, java.lang.String wsID, com.esri.arcgis.server.IServerContext ctx)
          Retrieves versions from a map's feature layers.
static java.lang.String getWorkspaceID(com.esri.arcgis.carto.IFeatureLayer layer)
          Creates key that uniquely distinguishes workspace connection and feature-class registration.
static com.esri.arcgis.geodatabase.IFeature moveFeature(com.esri.arcgis.geometry.ILine offset, com.esri.arcgis.geodatabase.IFeature source)
          Moves the feature with the given offset.
static com.esri.arcgis.geometry.IGeometry moveVertex(double searchDistance, com.esri.arcgis.geometry.IGeometry geom, com.esri.arcgis.geometry.ILine line, com.esri.arcgis.server.IServerContext ctx)
          Moves a vertex from the start point to the end point of the line.
static com.esri.arcgis.geometry.IGeometry removeVertex(double searchDistance, com.esri.arcgis.geometry.IGeometry geom, com.esri.arcgis.geometry.IPoint point, com.esri.arcgis.server.IServerContext ctx)
          Removes a vertex the geometry if it is in the search distance.
static com.esri.arcgis.geodatabase.IFeatureCursor search(com.esri.arcgis.geometry.IEnvelope extent, com.esri.arcgis.carto.IFeatureLayer layer, com.esri.arcgis.server.IServerContext ctx)
          Gets all features on the layer within the given bounds.
static com.esri.arcgis.geodatabase.IFeature simplifyGeometry(com.esri.arcgis.geodatabase.IFeature feature, com.esri.arcgis.geometry.IGeometry geom)
          Simplifies the geometry.
static java.util.List<com.esri.arcgis.geodatabase.IFeature> splitLineFeature(com.esri.arcgis.geodatabase.IFeature feature, com.esri.arcgis.geometry.IPoint pt, double searchDistance, com.esri.arcgis.server.IServerContext ctx)
          Splits a line feature to two.
static java.util.List<com.esri.arcgis.geodatabase.IFeature> splitPolygonFeature(com.esri.arcgis.geodatabase.IFeature feature, com.esri.arcgis.geometry.IPolyline polyline)
          Splits a polygon feature to two.
static double toDistance(int pixels, com.esri.arcgis.geometry.IEnvelope bounds, int imageWidth, com.esri.arcgis.geometry.ISpatialReference refTo)
          Converts the screen pixels to map distance in the spatial reference's unit.
static com.esri.arcgis.geometry.IEnvelope toEnvelope(double minx, double miny, double maxx, double maxy, com.esri.arcgis.geometry.ISpatialReference ref, com.esri.arcgis.server.IServerContext ctx)
          Converts the WebExtent to an Envelope.
static com.esri.arcgis.geometry.ILine toILine(double x1, double y1, double x2, double y2, com.esri.arcgis.geometry.ISpatialReference ref, com.esri.arcgis.server.IServerContext ctx)
          Creates a ILine from 2 points.
static com.esri.arcgis.geometry.ILine toLine(double x1, double y1, double x2, double y2, com.esri.arcgis.geometry.ISpatialReference ref, com.esri.arcgis.server.IServerContext ctx)
          Creates a ILine from 2 points.
static com.esri.arcgis.geometry.IPoint toPoint(double x, double y, com.esri.arcgis.geometry.ISpatialReference ref, com.esri.arcgis.server.IServerContext ctx)
          Creates a IPoint from x,y.
static com.esri.arcgis.geodatabase.IFeature updateAttribute(com.esri.arcgis.geodatabase.IFeature feature, Attribute att, java.text.DateFormat dateFormat)
          Updates an attribute value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOT_VERSIONED

public static final java.lang.String NOT_VERSIONED
See Also:
Constant Field Values
Constructor Detail

EditUtil

public EditUtil()
Method Detail

copyFeature

public static com.esri.arcgis.geodatabase.IFeature copyFeature(com.esri.arcgis.carto.IFeatureLayer targetLayer,
                                                               com.esri.arcgis.geometry.ILine offset,
                                                               com.esri.arcgis.geodatabase.IFeature source)
                                                        throws java.io.IOException,
                                                               com.esri.arcgis.interop.AutomationException
Copies the feature to the target layer and move it with the given offset. The new feature will not be stored by default, you need to store it explicitly.
 IFeature fNew = EditorUtil.copyFeature(workspace.getLayer(), offset, feature);
 fNew.store();
 

Parameters:
targetLayer - the layer to copy to.
offset - the offset of the feature position. Set to null for no offset.
source - the feature to copy.
Returns:
the reference of the new Feature.
Throws:
java.io.IOException - If there are interop problems.
com.esri.arcgis.interop.AutomationException - If the ArcObject component throws an exception.

moveFeature

public static com.esri.arcgis.geodatabase.IFeature moveFeature(com.esri.arcgis.geometry.ILine offset,
                                                               com.esri.arcgis.geodatabase.IFeature source)
                                                        throws java.io.IOException,
                                                               com.esri.arcgis.interop.AutomationException
Moves the feature with the given offset. The new feature will not be stored by default, you need to store it explicitly.
 IFeature fNew = EditorUtil.copyFeature(workspace.getLayer(), offset, feature);
 fNew.store();
 

Parameters:
offset - the offset of the feature position. Set to null for no offset.
source - the feature to copy.
Returns:
the reference of the new Feature.
Throws:
java.io.IOException - If there are interop problems.
com.esri.arcgis.interop.AutomationException - If the ArcObject component throws an exception.

createFeature

public static com.esri.arcgis.geodatabase.IFeature createFeature(com.esri.arcgis.carto.IFeatureLayer editLayer,
                                                                 com.esri.arcgis.geometry.IGeometry geom)
                                                          throws java.lang.Exception
Creates a geometry to a feature layer. The feature will not be stored be default.

Parameters:
editLayer - a feature layer
geom - geometry
Returns:
the feature or null if not succeed..
Throws:
java.lang.Exception

getSelection

public static com.esri.arcgis.geodatabase.IFeatureCursor getSelection(com.esri.arcgis.carto.IFeatureLayer editLayer,
                                                                      com.esri.arcgisws.LayerDescription ldesc,
                                                                      com.esri.arcgis.server.IServerContext ctx)
                                                               throws java.lang.Exception
Gets the selected feature on the given layer.

Parameters:
editLayer - the layer to search.
Returns:
the feature cursor.
Throws:
java.io.IOException
com.esri.arcgis.interop.AutomationException
java.lang.Exception

getFeatures

public static com.esri.arcgis.geodatabase.IFeatureCursor getFeatures(com.esri.arcgis.carto.IFeatureLayer editLayer,
                                                                     int[] oids,
                                                                     com.esri.arcgis.server.IServerContext ctx)
                                                              throws java.lang.Exception
Gets the features by the given object IDs.

Parameters:
editLayer - the layer to search.
Returns:
the feature cursor.
Throws:
java.lang.Exception

getWorkspaceID

public static java.lang.String getWorkspaceID(com.esri.arcgis.carto.IFeatureLayer layer)
Creates key that uniquely distinguishes workspace connection and feature-class registration.

Parameters:
layer - target feature layer.
Returns:
the workspace ID

getFeatureLayers

public static java.util.Map<java.lang.Integer,com.esri.arcgis.carto.IFeatureLayer> getFeatureLayers(com.esri.arcgis.carto.IMap map,
                                                                                                    com.esri.arcgis.server.IServerContext ctx)
                                                                                             throws java.lang.Exception
Gets all feature layers from the IMap.

Parameters:
map - the IMap instance.
ctx - server context
Returns:
the index and feature layer pairs in a Map.
Throws:
java.lang.Exception

toEnvelope

public static com.esri.arcgis.geometry.IEnvelope toEnvelope(double minx,
                                                            double miny,
                                                            double maxx,
                                                            double maxy,
                                                            com.esri.arcgis.geometry.ISpatialReference ref,
                                                            com.esri.arcgis.server.IServerContext ctx)
                                                     throws java.lang.Exception
Converts the WebExtent to an Envelope.

Parameters:
ctx - set to null to use ArcObject.
Throws:
java.lang.Exception

toPoint

public static com.esri.arcgis.geometry.IPoint toPoint(double x,
                                                      double y,
                                                      com.esri.arcgis.geometry.ISpatialReference ref,
                                                      com.esri.arcgis.server.IServerContext ctx)
                                               throws java.lang.Exception
Creates a IPoint from x,y.

Parameters:
ctx - set to null to use ArcObject.
Throws:
java.lang.Exception

toLine

public static com.esri.arcgis.geometry.ILine toLine(double x1,
                                                    double y1,
                                                    double x2,
                                                    double y2,
                                                    com.esri.arcgis.geometry.ISpatialReference ref,
                                                    com.esri.arcgis.server.IServerContext ctx)
                                             throws java.lang.Exception
Creates a ILine from 2 points.

Parameters:
ctx - set to null to use ArcObject.
Throws:
java.lang.Exception

search

public static com.esri.arcgis.geodatabase.IFeatureCursor search(com.esri.arcgis.geometry.IEnvelope extent,
                                                                com.esri.arcgis.carto.IFeatureLayer layer,
                                                                com.esri.arcgis.server.IServerContext ctx)
                                                         throws java.lang.Exception
Gets all features on the layer within the given bounds.

Parameters:
extent - the search bounds
layer - the layer to search
ctx - server context
Returns:
the cursor.
Throws:
java.lang.Exception

toILine

public static com.esri.arcgis.geometry.ILine toILine(double x1,
                                                     double y1,
                                                     double x2,
                                                     double y2,
                                                     com.esri.arcgis.geometry.ISpatialReference ref,
                                                     com.esri.arcgis.server.IServerContext ctx)
                                              throws java.lang.Exception
Creates a ILine from 2 points.

Throws:
java.lang.Exception

getAttributes

public static java.util.Map<java.lang.Integer,Attribute> getAttributes(com.esri.arcgis.carto.IFeatureLayer fLayer,
                                                                       com.esri.arcgis.geodatabase.IFeature feature,
                                                                       AttributeFilter filter,
                                                                       java.text.DateFormat dateFormat)
                                                                throws java.lang.Exception
Gets all the editable attributes on the feature.

Parameters:
fLayer - the layer from which the feature retrieved.
feature - the feature from which the attributes retrieved.
filter - to control how to display attributes.
dateFormat - to format date type attribute. Set to null to use the default date and time format.
Returns:
the index and attribute pairs.
Throws:
java.lang.Exception

updateAttribute

public static com.esri.arcgis.geodatabase.IFeature updateAttribute(com.esri.arcgis.geodatabase.IFeature feature,
                                                                   Attribute att,
                                                                   java.text.DateFormat dateFormat)
                                                            throws java.lang.Exception
Updates an attribute value. The feature will not be store.

Parameters:
feature - the feature to update
att - the changed attribute.
dateFormat - the parse the date string. Set to null to use the default date and time format.
Returns:
the updated feature
Throws:
java.lang.Exception

addVertex

public static com.esri.arcgis.geometry.IGeometry addVertex(double searchDistance,
                                                           com.esri.arcgis.geometry.IGeometry geom,
                                                           com.esri.arcgis.geometry.IPoint point,
                                                           com.esri.arcgis.server.IServerContext ctx)
                                                    throws java.lang.Exception
Adds a vertex the geometry if it is in the search distance.

Parameters:
searchDistance - the search distance in unit of geometry spatial reference.
geom - the geom to hit.
point - the vertex point
Returns:
return the new geometry or null if no geometry hit.
Throws:
java.lang.Exception

getSpatialReference

public static com.esri.arcgis.geometry.ISpatialReference getSpatialReference(com.esri.arcgis.carto.IFeatureLayer flayer)
                                                                      throws java.io.IOException,
                                                                             com.esri.arcgis.interop.AutomationException
Gets spatial reference from a feature layer.

Parameters:
flayer - the layer
Throws:
java.io.IOException
com.esri.arcgis.interop.AutomationException

toDistance

public static double toDistance(int pixels,
                                com.esri.arcgis.geometry.IEnvelope bounds,
                                int imageWidth,
                                com.esri.arcgis.geometry.ISpatialReference refTo)
                         throws java.io.IOException,
                                com.esri.arcgis.interop.AutomationException
Converts the screen pixels to map distance in the spatial reference's unit.

Parameters:
pixels - the pixel value.
bounds - the map bounds.
imageWidth - the map width in pixels.
refTo - the spatial reference of the target layer or map.
Returns:
the distance in the spatial reference's unit.
Throws:
java.io.IOException - If there are interop problems.
com.esri.arcgis.interop.AutomationException - If the ArcObject component throws an exception.

moveVertex

public static com.esri.arcgis.geometry.IGeometry moveVertex(double searchDistance,
                                                            com.esri.arcgis.geometry.IGeometry geom,
                                                            com.esri.arcgis.geometry.ILine line,
                                                            com.esri.arcgis.server.IServerContext ctx)
                                                     throws java.lang.Exception
Moves a vertex from the start point to the end point of the line.

Parameters:
searchDistance - the search distance in geometry's unit.
geom - the target geometry
line - the line to move along with.
Returns:
the new geometry or null if none geometry in the search distance.
Throws:
java.lang.Exception

simplifyGeometry

public static com.esri.arcgis.geodatabase.IFeature simplifyGeometry(com.esri.arcgis.geodatabase.IFeature feature,
                                                                    com.esri.arcgis.geometry.IGeometry geom)
                                                             throws java.lang.Exception
Simplifies the geometry.

Parameters:
feature - the feature to set
geom - the geometry to simplify
Returns:
the feature with the simplified geometry.
Throws:
java.lang.Exception

removeVertex

public static com.esri.arcgis.geometry.IGeometry removeVertex(double searchDistance,
                                                              com.esri.arcgis.geometry.IGeometry geom,
                                                              com.esri.arcgis.geometry.IPoint point,
                                                              com.esri.arcgis.server.IServerContext ctx)
                                                       throws java.lang.Exception
Removes a vertex the geometry if it is in the search distance.

Parameters:
searchDistance - the search distance in unit of geometry spatial reference.
geom - the geom to hit.
point - the vertex point
Returns:
return the new geometry or null if no geometry hit.
Throws:
java.lang.Exception

splitLineFeature

public static java.util.List<com.esri.arcgis.geodatabase.IFeature> splitLineFeature(com.esri.arcgis.geodatabase.IFeature feature,
                                                                                    com.esri.arcgis.geometry.IPoint pt,
                                                                                    double searchDistance,
                                                                                    com.esri.arcgis.server.IServerContext ctx)
                                                                             throws java.lang.Exception
Splits a line feature to two.

Parameters:
feature - the feature to split
pt - the split point
searchDistance - the search tolerance.
Returns:
the split result.
Throws:
java.lang.Exception

splitPolygonFeature

public static java.util.List<com.esri.arcgis.geodatabase.IFeature> splitPolygonFeature(com.esri.arcgis.geodatabase.IFeature feature,
                                                                                       com.esri.arcgis.geometry.IPolyline polyline)
                                                                                throws java.lang.Exception
Splits a polygon feature to two.

Parameters:
feature - the feature to split
polyline - the split line.
Returns:
the split result.
Throws:
java.lang.Exception

getSelection

public static com.esri.arcgis.geodatabase.IFeatureCursor getSelection(com.esri.arcgis.carto.IFeatureLayer editLayer,
                                                                      com.esri.arcgisws.LayerDescription ldesc,
                                                                      com.esri.arcgis.geometry.IGeometry geometry,
                                                                      com.esri.arcgis.server.IServerContext ctx)
                                                               throws java.lang.Exception
Gets the selected feature on the given layer intersected with the given geometry

Parameters:
editLayer - the layer to search.
Returns:
the feature cursor.
Throws:
java.io.IOException
com.esri.arcgis.interop.AutomationException
java.lang.Exception

getVersions

public static java.util.List<java.lang.String> getVersions(com.esri.arcgis.carto.IMap map,
                                                           java.lang.String wsID,
                                                           com.esri.arcgis.server.IServerContext ctx)
                                                    throws java.lang.Exception
Retrieves versions from a map's feature layers.

Parameters:
map - the source map.
wsID - the optional workspace id.
Returns:
the version name list. If the return list is empty, the map has no versioned layers. If the return list is not empty, and some layers are non-versioned layers, the non-version will be returned as a empty String "".
Throws:
java.lang.Exception