A Curious Animal
Bla, bla, bla, ..., (evolution) , ..., blog, blog, blog, ...
Bla, bla, bla, ..., (evolution) , ..., blog, blog, blog, ...
Sun, 23 May, 2010
When working with maps and geographical information systems styling features is very important, on one hand it can make your map more flashy and on the other it can help to classify or organize your features visually.For example, in a map where you show the most populated cities of the world you can use circles with different color and radius.
OpenLayers offers the option to style our features in different ways:
The order applying these style go from "out" to "in", that is, given a feature first is applied the layer style and later the concrete style the feature could have. And to show this nothing better than an example.
Supposing we have a Vector layer with some circles:
var vectorLayer = new OpenLayers.Layer.Vector("Vector");
// Create 50 random features, and give them a "type" attribute that
// will be used to style them by size.
var features = new Array(50);
for (var i=0; i<features.length; i++) {
features[i] = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(
(360 * Math.random()) - 180, (180 * Math.random()) - 90
), {
type: 5 + parseInt(5 * Math.random())
}
);
}
vectorLayer.addFeatures(features);
Now we define a layer style which applied to the layer and a feature style applied directly to a concrete feature:
var myStyles = new OpenLayers.StyleMap({
"default": new OpenLayers.Style({
pointRadius: 3, // sized according to type attribute
fillColor: "#ff5566",
strokeColor: "#ff9933",
strokeWidth: 2,
graphicZIndex: 1
})
});
vectorLayer.styleMap = myStyles;
features[0].style = {
pointRadius: 9, // sized according to type attribute
fillColor: "#225566",
strokeColor: "#ff9933",
strokeWidth: 4,
graphicZIndex: 1
};
As we expect the result is:

Fri, 14 May, 2010
Flexigrid is one of the most usefull and powerfull grid plugins for jQuery. Unfoirtunatelly, as ahotur explain in the project page, there is no much documentation so you must learn how to use it looking at existing code.
If anytime you need to fill a flexigrid with JSON or XML content and you are a little buggy to look at example code, here is the summary of history:
Sample data for both types are:
{
page: 1,
total: 2,
rows: [
{id: 'reg1', cell: ['reg1-cell1','reg1-cell2']},
{id: 'reg2', cell: ['reg2-cell1','reg2-cell2']}
]
}
Finally, to use your XML/JSON data to create a flexigrid component you need to:
<p id="yourId"></p>
$("#yourId").flexigrid({
url: 'your_file_name.json_or_xml',
dataType: 'json',
...
}
Now you know how to build a flashy flexigrid.
Wed, 12 May, 2010
One more time the benefits of you a widely used open source project has been demonstrated. Reading Developers Fix Drupal Module and Save Whitehouse.gov you can found that:
Earlier this week, a cross-site scripting vulnerability was discovered
in the module. Now the development team behind the Context module has
released version 6.x-2.0-rc4, which fixes the XSS vulnerability.
Wow, that's a couple of days to solve a problem. How many comercial projects can say the same?
Tue, 11 May, 2010
I have working on a web page using OpenLayers which among others shows a OpenStreetMap layer.
The issue is I need to move the mouse over the map and print on a label the tile name in the form level/x/y, for example, 5/15/10.
The first thing to do is to register a listener to the OpenLayers map object, then for every mouse event we need to get the lonlat and translate it from current map projection to the EPSG:4326 (WGS84).
map.events.register( 'mousemove', this, function(evt){
var lonlat = new OpenLayers.LonLat(0, 0);
if(evt){
lonlat = map.getLonLatFromPixel(evt.xy);
lonlat.transform(this.map.getProjectionObject(), new OpenLayers. Projection("EPSG:4326") );
}
tileX = long2tile(lonlat.lon, map.getZoom());
tileY = latg2tile(lonlat.lat, map.getZoom());
tileZ = map.getZoom();
});
To compute the tile X,Y grid coordinate from latlon you can use next functions, obtained from OpenStreetMaps site:
// Functions to compute tiles from lat/lon
function long2tile(lon,zoom) {
return (Math.floor((lon+180)/360*Math.pow(2,zoom)));
}
function lat2tile(lat,zoom) {
return (Math.floor((1-Math.log(Math.tan(lat*Math.PI/180) + 1/Math.cos(lat*Math.PI/180))/Math.PI)/2 *Math.pow(2,zoom)));
}
Sat, 1 May, 2010
Ptolemy goal is to build a good virtual globe SDK (open source project of course), easy to use and to extend by anyone.
The current version has some serious design problems and complex code which makes difficult to understand and extend for anyone who wants to contribute. Because this, recently Ptolemy project authors has started a period or re-foundation to build the project again from scratch.
The goal of re-foundation project are:
After that, we want to have a basic Virtual Globe SDK with a good design, implementation and documentation and, of course, stable enough to be used in any production environment :)
This way contributors will present their ideas, they will be discussed (using chat, email or Ptolemy group) and finally they will be briefly documented or explained and implemented.
In the next link you can follow the evolution of this amazing stage of the project: Ptolemy Refoundation.
As always you are welcome to participate actively.
Sun, 11 Apr, 2010
Wed, 10 Mar, 2010
This questions has come to me many times so it is time to write a post that acts as a reminder.
Currently I have a string lie
ftp://user:password@server/dirA/dirB/file
and what i want is parse it to get the user, password, server and path to the file (/dirA/dirB/file). My first try was:
ftp://(\S+):(\S+)@(\S+)(/\S+)
but that returns me server=server/dirA/dirB, which isn't what I want. The idea is that the group after the @ would make a non gready match. This is achieved using the ? char. So the final and right regular expression will becomes:
ftp://(\S+):(\S+)@(\S+?)(/\S+)
which returns server=server and file=/dirA/dirB/file.
Fri, 26 Feb, 2010
Many times we use small text files to store information like:
Some time ago I talk about MonkeyGTD, a GTD tool based on TiddlyWiki. Today I want simply recomend you TiddlyWiki for use instead text files.
TiddlyWiki is a JavaScript wiki formed by only one HTML file (with the JavaScript code in it). Every time you save new content a new HTML version file is created. All your content is in stored in the HTML. No need for a database. No need for a web server. I would prefer my content stores as a plain and separate text file (with some wiki format) but all together in a HTML file isn't bad.
Recent comments
9 weeks 6 hours ago
46 weeks 3 days ago
1 year 15 weeks ago
1 year 15 weeks ago