[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [udig-devel] how to create line Line2D teste = new Line2D.Double(new Double(e.x), new Double(e.y), e.x + 122, e.y + 15 ); TTTT = getContext().getDrawFactory() .createDrawShapeCommand(teste, Color.BLACK); TTTT.setStroke(133333, 0); //getContext().send
|
Hello Carlos,
I think you need to create a temporary layer to the map, and add the line to it. I did this last week, and I dont really know if is is the optimal way, but it worked.
Regards,
private void AddTempLayer() {
// obtain catalog or repository
ICatalog catalog = CatalogPlugin.getDefault().getLocalCatalog();
// What we finally add to the map are geo resources (shapefile layer,
// wms layer,...).
// we store them here before adding them to the map.
List<IGeoResource> dataHandles = new ArrayList<IGeoResource>();
// TEMP LAYER
// build feature type builder
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setName("Path");
builder.setNamespaceURI("http://localhost/");
builder.setCRS(DefaultGeographicCRS.WGS84);
// add attributes in order
builder.add("Location", LineString.class);
builder.add("ID", Integer.class);
builder.add("Name", String.class);
// build the type for the feature with attributes above
final SimpleFeatureType FLAG = builder.buildFeatureType();
// Create Feature (line)
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(FLAG);
// Create feature spatial field
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null);
WKTReader reader = new WKTReader(geometryFactory);
LineString line=null;
try {
line = (LineString) reader.read("LINESTRING(0 2, 2 0, 8 6)");
} catch (ParseException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
// add the attributes in order
featureBuilder.add(line);
featureBuilder.add(12);
featureBuilder.add("My Name");
// build the feature
SimpleFeature feature = featureBuilder.buildFeature("Flag.12");
// Create layer
IGeoResource tempLayer = catalog.createTemporaryResource(FLAG);
// Add feature to layer
FeatureStore fs = null;
try {
fs = tempLayer.resolve(FeatureStore.class, null);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
FeatureCollection features = FeatureCollections.newCollection();
features.add(feature);
try {
fs.addFeatures(features);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// add IGeoResource to data handles
dataHandles.add(tempLayer);
// Add geo resources list to the map
if (!dataHandles.isEmpty()) {
map.sendCommandASync(new AddLayersCommand(dataHandles));
}
}
Joaquín Rodríguez-Guerra Urcelay
Unidad de Sistemas de Procesamiento de Ciencia y de Observación de la Tierra / Science and Earth Observing Processing Systems Unit
GMV AEROSPACE AND DEFENCE, S.A.
Isaac Newton, 11
P.T.M. Tres Cantos
E-28760 Madrid
Tel. +34 91 807 21 00 / 7695
Fax +34 91 807 21 99
www.gmv.com
________________________________________
De: udig-devel-bounces@xxxxxxxxxxxxxxxxxxxxx [udig-devel-bounces@xxxxxxxxxxxxxxxxxxxxx] En nombre de carlos henrique de souza junior [carlos.henrique.s.j@xxxxxxxxx]
Enviado el: miércoles, 09 de marzo de 2011 2:30
Para: udig-devel@xxxxxxxxxxxxxxxxxxxxx
Asunto: [udig-devel] how to create line Line2D teste = new Line2D.Double(new Double(e.x), new Double(e.y), e.x + 122, e.y + 15 ); TTTT = getContext().getDrawFactory() .createDrawShapeCommand(teste, Color.BLACK); TTTT.setStroke(133333, 0); //getContext().send
hello guys my name is carlos
I'm starting to uDig and am with some doubts
how do I create a line and put this information online, to appear in
the view INFORMATION?
I tried from a code I found the map but when I move the line does not
move and do not know how to add information in this line
I found the code and used DrawShapeCommand getContext
Line2D teste = new Line2D.Double(new Double(e.x), new Double(e.y),
e.x + 122, e.y + 15 );
li = getContext().getDrawFactory()
.createDrawShapeCommand(teste, Color.BLACK);
li.setStroke(13, 0);
getContext().sendSyncCommand(li);
could you inform me how this is done or direct me where to study on this?
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel
______________________
This message including any attachments may contain confidential
information, according to our Information Security Management System,
and intended solely for a specific individual to whom they are addressed.
Any unauthorised copy, disclosure or distribution of this message
is strictly forbidden. If you have received this transmission in error,
please notify the sender immediately and delete it.
______________________
Este mensaje, y en su caso, cualquier fichero anexo al mismo,
puede contener informacion clasificada por su emisor como confidencial
en el marco de su Sistema de Gestion de Seguridad de la
Informacion siendo para uso exclusivo del destinatario, quedando
prohibida su divulgacion copia o distribucion a terceros sin la
autorizacion expresa del remitente. Si Vd. ha recibido este mensaje
erroneamente, se ruega lo notifique al remitente y proceda a su borrado.
Gracias por su colaboracion.
______________________
- Prev by Date:
[udig-devel] how to create line Line2D teste = new Line2D.Double(new Double(e.x), new Double(e.y), e.x + 122, e.y + 15 ); TTTT = getContext().getDrawFactory() .createDrawShapeCommand(teste, Color.BLACK); TTTT.setStroke(133333, 0); //getContext().send
- Next by Date:
Re: [udig-devel] how to create line
- Previous by thread:
[udig-devel] how to create line Line2D teste = new Line2D.Double(new Double(e.x), new Double(e.y), e.x + 122, e.y + 15 ); TTTT = getContext().getDrawFactory() .createDrawShapeCommand(teste, Color.BLACK); TTTT.setStroke(133333, 0); //getContext().send
- Next by thread:
[udig-devel] Create a line
- Index(es):