Projecting data on the fly using spatial references...

507
1
06-11-2010 05:51 AM
BillZborowski1
New Contributor
Hi Guys,

I'm building a search service to query unprojected attribute data, project it, and deliver the extent back to the client.  The method I'm using works unpredictably.  For are larger land parcels it re-projects perfectly find, but for really small land parcels, quarter sections, it won't reproject using the getEnvelope() method.  Can anyone offer some advice on how I might fix this problem?

Here is a snippet of the code:

// Step 2: Get reference to SOM.
IServerObjectManager som = conn.getServerObjectManager();
  
// Step 3: Get Map object reference.
IServerContext context = som.createServerContext("myGeodataService", "GeoDataServer");
IGeoDataServer gs = (IGeoDataServer)context.getServerObject();
  
// Step 4: Set up query filter.
IQueryFilter qf = (IQueryFilter)context.createObject(QueryFilter.getClsid());
StringBuffer whereClause = new StringBuffer("");
int i = 0;
for(CplDLSQuarter value: queryResults) {
 if(i == 0) whereClause.append("LAND_PARCEL_IDENTIFIER = '" + value.getLandParcelId() + "'");
 else whereClause.append(" OR LAND_PARCEL_IDENTIFIER = '" + value.getLandParcelId() + "'");
 ++i;
}
if (whereClause.length() > 1) qf.setWhereClause(whereClause.toString());
SpatialReferenceEnvironment srFactory = (SpatialReferenceEnvironment)context.createObject(SpatialReferenceEnvironment.getClsid());
ProjectedCoordinateSystem pcSystem = (ProjectedCoordinateSystem)srFactory.createESRISpatialReferenceFromPRJFile(ags.getProjectionsMap().get(proj));
qf.setOutputSpatialReferenceByRef("SHAPE", pcSystem);
  
IResultPortionInfo rpi = (IResultPortionInfo)context.createObject(ResultPortionInfo.getClsid());
rpi.setStartIndex(0);
rpi.setCount(gs.getMaxRecordCount());
  
IGDSQueryResultPortion resPortion = gs.tableSearch(
  gs.getDefaultWorkingVersion(), 
  "SCHEMA.SDE_TABLE", 
  qf, 
  rpi);
  
IRecordSet recs = resPortion.getRecords();
ICursor cursor = recs.getCursor(true);
IRow row;
while ((row = cursor.nextRow()) != null) {
 ResultType result = new ResultType();
 AttributesType attributes = new AttributesType();
  
 //get the polygon.
 Polygon poly = (Polygon)row.getValue(9);
 poly.setSpatialReferenceByRef(pcSystem);
 ExtentType extent = new ExtentType();
 extent.setMaxx(new BigDecimal(poly.getEnvelope().getXMax()));
 extent.setMaxy(new BigDecimal(poly.getEnvelope().getYMax()));
 extent.setMinx(new BigDecimal(poly.getEnvelope().getXMin()));
 extent.setMiny(new BigDecimal(poly.getEnvelope().getYMin()));
 result.setExtent(extent);
   
 //add the rest of the attributes.
 //attributes.getAttribute().add(CplUtils.replaceNull());
 attributes.getAttribute().add(CplUtils.replaceNull(poly.getSpatialReference().getName()));
 attributes.getAttribute().add(CplUtils.replaceNull(row.getValue(0).toString()));
 attributes.getAttribute().add(CplUtils.replaceNull(row.getValue(1).toString()));
 attributes.getAttribute().add(CplUtils.replaceNull(row.getValue(4).toString()));
 attributes.getAttribute().add(CplUtils.replaceNull(row.getValue(5).toString()));
 attributes.getAttribute().add(CplUtils.replaceNull(row.getValue(8).toString()));
    
 result.setAttributes(attributes);
 
 //attach result to results
 results.getResult().add(result);
}
0 Kudos
1 Reply
MelitaKennedy
Esri Notable Contributor
bzborow1;18473 wrote:
Hi Guys,


I'm building a search service to query unprojected attribute data, project it, and deliver the extent back to the client.  The method I'm using works unpredictably.  For are larger land parcels it re-projects perfectly find, but for really small land parcels, quarter sections, it won't reproject using the getEnvelope() method.  Can anyone offer some advice on how I might fix this problem?

QUOTE]

I am speculating that it could a problem with the resolution/domain values of the target spatialreference (less likely: the tolerance). Perhaps the resolution value is too large and the envelopes are collapsing. Another possibility is that the envelope, after projecting it, is distorted enough that it's collapsing. I think that would be more likely with 'long' sides--they should be densified to reflect what's happening when the data's projected, aren't.

Melita
0 Kudos