Error
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.

feature

The Best Shooting Challenges of the Year [Best Of 2011]
Saturday, 31 December 2011 17:00
The photographic prowess of our readers never ceases to amaze us. These ten collections feature the most jaw-dropping user-submitted images of the year—perhaps of the decade. More »


Read more: http://feeds.gawker.com/~r/gizmodo/full/~3/4xr--ydDC5E/the-best-shooting-challenges-of-the-year

 
Leaked: iPhone 5 "Assistant" Is Enhanced Crowd-Sourcing Voice Control Based on Siri [Leaks]
Sunday, 24 July 2011 16:00
Although it's not currently available in the iOS 5 developer beta, a new leak at 9to5Mac has indicated a curious voice control feature called Assistant could be making its way into the mysterious iPhone 5 when it launches. More »


Read more: http://feeds.gawker.com/~r/gizmodo/full/~3/NuLS4P5vtZ4/leaked-iphone-5-assistant-is-enhanced-crowd+sourcing-voice-control-based-on-siri

 
Is Facebook Planning Facial-Recognition For Photos? [Blip]
Tuesday, 05 April 2011 12:08
Judging by this hidden-away feature in the privacy settings of Facebook, we could be spending less time tagging people soon. Like with the facial-recognition feature in iPhoto, this technology is not always accurate, but if it cuts down on the time I have to spend using Facebook's awful upload system, then I'm fine with that. [Engadget] More »


Read more: http://feeds.gawker.com/~r/gizmodo/full/~3/wmUBgIyMVd8/is-facebook-planning-facial+recognition-for-photos

 
Main attempt to create a shape file with Polygons converted to LineStrings - Geotools - doesn't work
Sunday, 27 March 2011 00:52
// This is an attempt to take a shape file with multipolygons in it and convert it to one with linestrings.
//
//It doesn't work (which is why the shape file write is commented out).
//
//It does, however, display the new feature collection okay
//
// Libraries used come from
// http://www.vividsolutions.com/jts/jtshome.htm and
// http://docs.geotools.org/ (version 2.7)


/**
*
*/
package map.foremail;

import java.awt.Color;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import map.common.C;

import org.geotools.data.DefaultTransaction;
import org.geotools.data.FileDataStore;
import org.geotools.data.FileDataStoreFinder;
import org.geotools.data.Transaction;
import org.geotools.data.collection.CollectionFeatureSource;
import org.geotools.data.shapefile.ShapefileDataStore;
import org.geotools.data.shapefile.ShapefileDataStoreFactory;
import org.geotools.data.simple.SimpleFeatureCollection;
import org.geotools.data.simple.SimpleFeatureIterator;
import org.geotools.data.simple.SimpleFeatureSource;
import org.geotools.data.simple.SimpleFeatureStore;
import org.geotools.feature.AttributeTypeBuilder;
import org.geotools.feature.FeatureCollections;
import org.geotools.feature.simple.SimpleFeatureBuilder;
import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
import org.geotools.map.DefaultMapContext;
import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.geotools.styling.FeatureTypeStyle;
import org.geotools.styling.LineSymbolizer;
import org.geotools.styling.Style;
import org.geotools.styling.StyleBuilder;
import org.geotools.swing.JMapFrame;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.feature.type.AttributeDescriptor;
import org.opengis.feature.type.AttributeType;

import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.LineString;
import com.vividsolutions.jts.geom.MultiPolygon;

/**
* @author John
* Convert a multi-polygon shape file to a line-string shape file
*
* This displays the new collection okay, but blows up making the shape file
*/
public class TestConvertGeoTypes {
private static final boolean NEW = true; // If true, convert with new type. If false, create new collection, but use old type
private static final String TEMP_SHAPE_FILE = "tmp/TCGT.shp";

// Mainline
public static void main(String[] args) throws Exception {
// GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory( null );
// Coordinate[] coords = new Coordinate[] {
// new Coordinate(0, 2), new Coordinate(2, 0), new Coordinate(8, 6),
// new Coordinate(-2, 2), new Coordinate(-2, 0), new Coordinate(-8, 6),
// };
// LineString line = geometryFactory.createLineString(coords);

// Read shapefile composed of multipolygons
ShapefileDataStore oldStore = getDataStoreFromShapeFile(C.COUNTIES_IN);
SimpleFeatureSource oldSrc = oldStore.getFeatureSource();
SimpleFeatureCollection oldCol = oldSrc.getFeatures();

// Convert the polygons to linestrings
LineString[] lines = polys2lines(oldCol);

// Create new feature source for the line strings
SimpleFeatureType oldType = oldSrc.getSchema();
SimpleFeatureSource newSrc;
if ( NEW ) {
System.out.println("\n\n======= Making New One-String Source ======\n");
newSrc = makeNewSrc("New LineString", oldType, null, lines, "LineString", LineString.class);
} else {
System.out.println("\n\n======= Making Old Source ======\n");
Geometry[] geoms = getGeometriesFromFeatureColl(oldSrc.getFeatures());
newSrc = makeNewSrc("Rebuilt MultiPoly", oldType, null, geoms, "MultiPolygon", MultiPolygon.class);
}

// writeShapeFile(newSrc.getFeatures(), TEMP_SHAPE_FILE); // Commented out - fails

//
// Display on a map (this works)
//
DefaultMapContext map = new DefaultMapContext();
map.setTitle("Try Geo Conversion");
StyleBuilder sbldr = new StyleBuilder();
Style style = sbldr.createStyle();
LineSymbolizer liner = sbldr.createLineSymbolizer(Color.GREEN, 1);
// Rule rule = sbldr.createRule(line);
FeatureTypeStyle fts = sbldr.createFeatureTypeStyle(liner);
style.featureTypeStyles().add(fts);
map.addLayer(newSrc.getFeatures(), (Style)style);
JMapFrame.showMap(map);
}
//
// Convert mulipolygon features to array of linestrings
//
private static LineString[] polys2lines(SimpleFeatureCollection oldCol) {
SimpleFeatureIterator it = oldCol.features();
GeometryFactory fact = new GeometryFactory();
List al = new LinkedList();
while ( it.hasNext() ) {
SimpleFeature feature = it.next();
MultiPolygon mp = (MultiPolygon)feature.getAttribute(0);
int n = mp.getNumGeometries();
for ( int i = 0 ; i < n ; i++ ) {
Geometry g = mp.getGeometryN(i);
Coordinate[] coords = g.getCoordinates();
LineString ls = fact.createLineString(coords);
al.add(ls);
}
}
return al.toArray(new LineString[al.size()]);
}
//
// Make a new feature source, based on old type but convert to new type
//
private static SimpleFeatureSource makeNewSrc(String srcName, SimpleFeatureType oldType, SimpleFeatureType typeToUse, Geometry[] geoms, String geoTypeStr, Class geoClass) throws IOException {
AttributeDescriptor[] ads = oldType.getAttributeDescriptors().toArray(new AttributeDescriptor[oldType.getAttributeCount()]);
AttributeDescriptor newAttDesc = makeAttributeDescriptor("the_geom", geoTypeStr, geoClass);
ads[0] = newAttDesc;

SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
// b.addAll(ads);
b.addAll(ads );
b.setCRS( oldType.getCoordinateReferenceSystem());
b.setName( srcName );
b.setDefaultGeometry("the_geom");
SimpleFeatureType newFeatureType = b.buildFeatureType();

SimpleFeatureSource newSrc = makeFeatureSourceGivenReference(Arrays.asList(geoms), typeToUse == null ? newFeatureType : typeToUse);
return newSrc;
}
//
// Make data store based on a shape file
public static ShapefileDataStore getDataStoreFromShapeFile(String fnameIn) throws Exception {
FileDataStore fds = FileDataStoreFinder.getDataStore(new File(fnameIn));
ShapefileDataStore shpStore = (ShapefileDataStore)fds;
return shpStore;
}
//
// Get all geometries from the feature collection (assume it is a multipolygon type)
public static Geometry[] getGeometriesFromFeatureColl(SimpleFeatureCollection col) {
List geomList = new ArrayList();
SimpleFeatureIterator it = col.features();
while ( it.hasNext() ) {
SimpleFeature feature = it.next();
// Note assuming here that we have a polygon shapefile
Geometry dfltGeom = (Geometry)feature.getDefaultGeometry();
if ( dfltGeom instanceof MultiPolygon ) {
MultiPolygon mp = (MultiPolygon) feature.getDefaultGeometry();
final int n = mp.getNumGeometries();
for (int i = 0; i < n; i++) {
geomList.add(mp.getGeometryN(i));
}
} else if ( dfltGeom instanceof LineString ) {
geomList.add((LineString)dfltGeom.getGeometryN(0));
}
}
return geomList.toArray(new Geometry[geomList.size()]);
}
//
// Write a shape file based from a feature collection
public static void writeShapeFile(SimpleFeatureCollection col, String name) throws Exception {
File newFile = new File(name);

ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();

Map params = new HashMap();
params.put("url", newFile.toURI().toURL());
params.put("create spatial index", Boolean.TRUE);

ShapefileDataStore newDataStore = (ShapefileDataStore) dataStoreFactory.createNewDataStore(params);
SimpleFeatureType schema = col.getSchema();
schema.getGeometryDescriptor();
newDataStore.createSchema(schema);
newDataStore.forceSchemaCRS(DefaultGeographicCRS.WGS84);
Transaction transaction = new DefaultTransaction("create");

String typeName = newDataStore.getTypeNames()[0];
SimpleFeatureSource featureSource = newDataStore.getFeatureSource(typeName);

if (featureSource instanceof SimpleFeatureStore) {
SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;

featureStore.setTransaction(transaction);
try {
featureStore.addFeatures(col);
transaction.commit();

} catch (Exception problem) {
problem.printStackTrace();
transaction.rollback();

} finally {
transaction.close();
}
System.exit(0); // success!
} else {
System.out.println(typeName + " does not support read/write access");
System.exit(1);
}
}
//
// Make an attribute descriptor
public static AttributeDescriptor makeAttributeDescriptor(String descName, String typeName, Class clazz) {
AttributeTypeBuilder tbld = new AttributeTypeBuilder();

//set type information
tbld.setName( typeName );
tbld.setBinding( clazz );
tbld.setNillable( false );

//build the type
AttributeType atype = tbld.buildType();
AttributeTypeBuilder builder = new AttributeTypeBuilder();

//set type information
builder.setBinding( LineString.class );
builder.setNillable( false );

//set descriptor information
builder.setMinOccurs(0);
builder.setMaxOccurs(1);
builder.setNillable(true);

//build the descriptor
AttributeDescriptor descriptor = builder.buildDescriptor(descName, atype);
return descriptor;
}
//
// Make a feature source given a reference feature type
public static SimpleFeatureSource makeFeatureSourceGivenReference(Collection geometries, SimpleFeatureType refType) {
int i = 0;
SimpleFeatureCollection newCollection = FeatureCollections.newCollection();
for ( Geometry g : geometries ) {
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(refType);

//add the attributes
builder.add( g );
builder.add( "the_geom" );

//build the feature
SimpleFeature feature = builder.buildFeature( ""+(i++) );
newCollection.add(feature);
}
CollectionFeatureSource src = new CollectionFeatureSource(newCollection);
return src;
}

}


Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/4L0X_uhxa5E/13059

 
Amazon Takes Away Kindle API for Book Sharing Site Lendle [Amazon]
Monday, 21 March 2011 21:20
eBook sharing site Lendle has lost access to Amazon's eBook APIs, effectively shutting them down. Lendle took advantage of the Kindle book lending feature, connecting random users who wanted to swap books digitally. More »


Read more: http://feeds.gawker.com/~r/gizmodo/full/~3/g7sJUfGx_Pw/amazon-takes-away-kindle-api-for-book-sharing-site-lendle

 
Start
Prev
1


Page 1 of 2
Taxonomy by Zaragoza Online