[OpenLayers-Users] Geometry.Collection (LineString) GetCentroid
- fake?
Andreas Hocevar
ahocevar at opengeo.org
Wed Feb 17 05:11:40 EST 2010
Hi,
see http://trac.openlayers.org/ticket/2469
Regards,
Andreas.
On 2010-02-17 09:18, BrainDrain wrote:
> Hi.
> I use this function to locate geometry on map
> OpenLayers.Map.prototype.locate = function(geometry, panOnly) {
> var bounds = geometry.getBounds();
> //this.zoomToExtent(bounds);
> //this.zoomToScale(scale);
> if ((this.getExtent().containsBounds(bounds) ||
> this.getZoomForExtent(bounds) > this.zoom) || panOnly) {
> //wrong for complex LineStrings (points to the center of the extent - not
> center of the geometry)
> //this.panTo(bounds.getCenterLonLat());
>
> //incorrect with current implemetation of
> Geometry.Collection GetCentroid
> //this.panTo(WEM.Util.point2ll(geometry.getCentroid()));
>
> var parser = new OpenLayers.Format.WKT();
> //this works - BUT! I need to send all geometry WKT
> to the server
> //server (MapServer mapscript c# via webservice
> webmetod) getCentroid works perfectly
> application.server.MapParser.GetCentroid(parser.write(geometry),
> function(geometryWKT, scope) {
> scope.panTo(WEM.Util.point2ll(parser.read(geometryWKT).geometry));
> }, null, this);
> }
> else {
> var zoom = this.zoom;
> this.zoomToExtent(bounds);
> this.zoomTo(zoom);
> }
> };
>
> What's this (for ex. for LineString)???
> /**
> * APIMethod: getCentroid
> *
> * Returns:
> * {<OpenLayers.Geometry.Point>} The centroid of the collection
> */
> getCentroid: function() {
> return this.components.length && this.components[0].getCentroid();
> //just great)))(((!
> }
>
> Currently I can:
> - pass only featureId to the server (not all geometry text)
> - get centroid forcibly on server on querying features and then use it
> - compress geometry WKT with JavaScript lib (deflate) and decompress on
> server as I do it on update feature....
> But I want correct getCentroid implemetation
>
--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
More information about the Users
mailing list