I little confused with the coordinates . Any how i got the answer by
creating polygons with latllong(georeferenced) values instead of creating
with XY (original) values. thanks.
/*- – - – - – – - – – - – – - – – - – – - – – - – – - – – - – – - – – - -
Please consider your environmental responsibility.
Before printing this e-mail message, ask yourself whether you really need a
hard copy.
Life is what happens to you, while you're busy making other plans
We do not inherit the earth from our ancestors; we borrow it from our
children.
Leave them a living planet reduce your carbon foot print.
------------------------------------------------------------
--------------------------------*/
yours suri chinna
On Tue, Oct 14, 2014 at 9:56 PM, Jody Garnett <jody.garn...@gmail.com>
wrote:
> I am not sure I understand where you are stuck? What do you mean by "including
> geodetic coordinates" ?
>
> Jody Garnett
>
> On Mon, Oct 13, 2014 at 10:57 PM, suri <surendranath1...@gmail.com> wrote:
>
>>
>> I have collections of polygon features. Each point in a polygon has local
>> cooridantes (x y values) and geodetic Coordinates (latitude and longitude
>> in decimal degree computed externaly) i can export the shape file(vector)
>> with xy values using geotools.
>>
>> How can i export the data by including geodetic coordinates?
>>
>>
>> Point - X Y values - correspoinding latitude and longitude
>>
>> Polygon points have coordinates with (x y values) i have find the latlong
>> values for each point in the shapefile externally by using rubbersheeting
>> method given in
>> http://www.corrmap.com/features/rubber-sheeting_transformation.php now i
>> need to project the lat long values into the shapefile along with x y
>> values of the points.
>>
>>
>> Polygons [ p1,p2,p3,p4........soon]
>> p1 - (x ,y) already in the shapefile (lat, long) computed externally.
>>
>> id-->*******x********y***************lon*********lat
>>
>> 79-->(8912.811,1481.9799):(80.205185,13.336138)
>>
>> 80-->(8912.811,1481.9766):(80.205185,13.336108)
>>
>> 93-->(8912.656,1481.9835):(80.2038,13.336171)
>>
>> 140-->(8912.8125,1482.0161):(80.20521,13.336465)
>>
>>
>> My code for exporting shape file with x and y coordinates and i need to
>> include projection (lat long).
>>
>> /**
>> * Writes the Shapes in the featureList into the given File
>> *
>> * @param theFile Reference to the File
>> * @param featureList The list of features to be written
>> *
>> * @return TRUE if successfully written; Else FALSE
>> */
>> public boolean writeShape(File theFile, List featureList) throws
>> Exception
>> {
>> ShapefileDataStoreFactory dSFactory = new
>> ShapefileDataStoreFactory();
>>
>> Map params = new HashMap();
>> params.put("url", theFile.toURI().toURL());
>> params.put("create spatial index", Boolean.TRUE);
>>
>> ShapefileDataStore newDataStore =
>> (ShapefileDataStore)
>> dSFactory.createNewDataStore(params);
>>
>> newDataStore.createSchema(featureBuilder.getFeatureType());
>> newDataStore.forceSchemaCRS(DefaultGeographicCRS.WGS84);
>>
>> String typeName = newDataStore.getTypeNames()[0];
>> SimpleFeatureSource featureSource =
>>
>> newDataStore.getFeatureSource(typeName);
>>
>> boolean success = false;
>> if (featureSource instanceof SimpleFeatureStore)
>> {
>> SimpleFeatureStore featureStore =
>> (SimpleFeatureStore)featureSource;
>>
>> SimpleFeatureCollection collection =
>> new
>> ListFeatureCollection(featureBuilder.getFeatureType(),
>> featureList);
>>
>> Transaction transaction = new DefaultTransaction("create");
>> featureStore.setTransaction(transaction);
>>
>> try
>> {
>> featureStore.addFeatures(collection);
>> transaction.commit();
>> success = true;
>> }
>> catch (Exception exp)
>> {
>> if (DEBUG) exp.printStackTrace();
>> transaction.rollback();
>> success = false;
>> }
>> finally
>> {
>> transaction.close();
>> }
>> }
>>
>> if (success) showMessage(sCreated);
>> return success;
>> }
>>
>> private SimpleFeatureBuilder createFeatureBuilder()
>> {
>> SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
>> builder.setCRS(DefaultGeographicCRS.WGS84);
>> builder.setName(plotName);
>>
>> builder.add(sPolygon, Polygon.class);
>> builder.length(32).add(plotName, String.class);
>> builder.length(32).add(sArea, String.class);
>>
>> final SimpleFeatureType featureType = builder.buildFeatureType();
>> return new SimpleFeatureBuilder(featureType);
>> }
>>
>> public boolean addPolygonFeature(List featureList, Point3D[]
>> thePoints,
>> String polyId, float area) throws
>> Exception
>> {
>> Polygon aPoly = createPolygon(thePoints);
>>
>> if (aPoly == null)
>> {
>> StringBuffer buf = new StringBuffer();
>> buf.append(WError1);
>> buf.append(polyId);
>> buf.append(WError2);
>> String error = buf.toString();
>>
>> int opt = GUIBase.showConfirmDialog(error, "Confirm", GUI_YN);
>> return (opt == GUIBase.GUI_YES);
>> }
>>
>> SimpleFeature feature = featureBuilder.buildFeature(null);
>> feature.setAttribute(plotName, polyId);
>> feature.setAttribute(sPolygon, aPoly);
>> feature.setAttribute(sArea, area);
>> featureList.add(feature);
>> return true;
>> }
>>
>> /**
>> * Creates a polygon feature from Array of FMBPoints
>> *
>> * @param thePoints Array of Point3Ds
>> *
>> * @return Reference to the Polygon object
>> */
>> public static Polygon createPolygon(Point3D[] thePoints)
>> {
>> int count = (thePoints == null) ? 0 : thePoints.length;
>> if (count < 1) return null;
>>
>> // Store Coordinates of polygon as a LINESTRING.
>> StringBuffer buffer = new StringBuffer();
>> buffer.append("POLYGON((");
>>
>> for (int i=0; i<count; i++)
>> {
>> buffer.append(thePoints[i].x);
>> buffer.append(SPACE);
>> buffer.append(thePoints[i].y);
>> buffer.append(COMMA);
>> }
>>
>> String lineString = buffer.toString();
>> lineString = lineString.substring(0, lineString.length()-1) +
>> "))";
>> if (DEBUG) System.out.println(lineString);
>>
>> try
>> {
>> // Creating the Geometry (Polygon)
>> return (Polygon) wktReader.read(lineString);
>> }
>> catch (Exception excep) { }
>>
>> return null;
>> }
>>
>>
>>
>> /*- – - – - – – - – – - – – - – – - – – - – – - – – - – – - – – - – – - -
>>
>> Please consider your environmental responsibility.
>> Before printing this e-mail message, ask yourself whether you really need
>> a hard copy.
>>
>> Life is what happens to you, while you're busy making other plans
>>
>> We do not inherit the earth from our ancestors; we borrow it from our
>> children.
>> Leave them a living planet reduce your carbon foot print.
>> ------------------------------------------------------------
>> --------------------------------*/
>>
>>
>>
>>
>>
>>
>> yours suri chinna
>>
>>
>> ------------------------------------------------------------------------------
>> Comprehensive Server Monitoring with Site24x7.
>> Monitor 10 servers for $9/Month.
>> Get alerted through email, SMS, voice calls or mobile push notifications.
>> Take corrective actions from your mobile device.
>> http://p.sf.net/sfu/Zoho
>> _______________________________________________
>> GeoTools-GT2-Users mailing list
>> GeoTools-GT2-Users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>>
>>
>
------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users