Estimating a circle using a polygon
Here's working java code for getting the edges of such a polygon, given the radius and center of the circle.
public Coordinate[] getCircle(Double lat,Double lng, Double radius)
{
int points = 32;
Double d2r = Math.PI / 180; // degrees to radians
Double r2d = 180 / Math.PI; // radians to degrees
Double earthsradius = 3963.0;
Double rlat = (radius / earthsradius) * r2d;
Double rlng = rlat / Math.cos(lat * d2r);
Coordinate[] list = new Coordinate[points+1];
for(int i=0;i
Double theta = (double)i/(double)points * 2 *Math.PI;
Double ey = lng + (rlng * Math.cos(theta));
Double ex = lat + (rlat * Math.sin(theta));
list[i] = new Coordinate(ex,ey);
}
// make sure the circle is complete
list[points]=list[0];
return list;
}
Friday, June 21, 2013 | 0 Comments
Time to run
Rang De is social initiative that supports rural entrepreneurs across India by providing them with low cost loans for their businesses. Typically they run eateries, cottage industries, vegetable shops and so on. Since otherwise, their only access to capital is the local moneylender, it is anyone's guess on how their life shapes up after that.
Rang De is an innovative attempt to break this cycle of poverty. Through the online portal, individuals can make social investments by lending small sums of money to entrepreneurs of their choice. I invite you to www.rangde.org to understand more about how it works.
For the past year i have been an active volunteer with RangDe and have been involved in various activities from fund raising, publicity to some field work interacting with borrowers and field partners. In this time I have personally seen the difference Rang De is making in the rural landscape and am now a firm supporter of the cause.
Here are two ways in which you can support my initiative
1 Become a social investor on rangde. Invest any amount starting from just Rs 100. Instructions here http://bit.ly/dXxGfa .
2 Raise a pledge as small or large as you please. Heres my online giving page http://bit.ly/fQ2ZxY.
Since this is a donation, the money will not be returned to you, but will be invested and reinvested over and over to fund needy entrepreneurs.
Tuesday, January 04, 2011 | 0 Comments
Rang De Conclave '10
I attended the Rang De Conclave '10 at Mahabalipuram, Chennai over the weekend. The conclave is the time of the year when the entire Rang De ecosystem consisting of the Rang De team, field partners & volunteers from across India come together to evaluate their plans, learn from each other and plan ahead.
Monday, December 06, 2010 | 0 Comments
The Colour of Dreams
"Its time for scheduling a field trip", was the subject of the mail, that made me quickly drop my work and take notice . It was Diksha from the Rang De Chennai office, planning the an evaluation field trips to one of the Rang De field partners. I always look forward to Rang De field trips as an opportunity to interact with small entrepreneurs bringing about a change in rural India, their unending enthusiasm and the difference a small social investment can make. It was my second field trip with Rang De , this time to Pusad where the Rang De field partner SAGRAS is based. After a long and delayed train journey 7 of us fieldtrippers reached Akola on friday afternoon, only to take on another bumpy but enjoyable bus ride to Pusad. As we reached the SAGRAS office late evening, 7 hours later than we were expected, we were surprised to find their entire team patiently waiting to welcome us. Over a cup of tea the entire team introduced themselves and gave us all the latest updates on their work and the various projects they work on. Early next morning we were all excited as we set off to visit each of the borrowers individually. We would enquire about their business, get updates on how the loan was utilized and also get their feedback on the entire loan process. Each of the borrowers has an interesting story to tell. As we saw the working of a cycle shop, I couldn't stop doing some calculations in my mind. With a loan of a mere 3000 Rs, the woman bought two new cycles that she now rents out, getting a fixed income of 50 a day. And i don't think twice before spending 3000 Rs on a single dinner at a fancy restaurant ! The next lady we met runs a tailoring business. She had not only expanded her business with the loan but now manages to support her daughter in doing a diploma is fashion technology. And you'd think only people in cities dream big !! Another family just managing to make ends meet with their small income distributing milk, has now started a business of making paneer and selling it to the local hotels for a decent profit. As we went on with these visits we were struck by the optimism of the women folk. Each one had big dreams for their families and their business, and surprisingly educating their kids was the foremost on their agenda. It is only when they get stuck in the cycle of debt and in the fight to make ends meet that they lose track of their priorities. They just need a hand in kick starting their journey, someone who would trust them and guide them. Mentoring is another area where Rang De's field partner SAGRAS is making a huge difference. At the core of SAGRAS are people who have been working in the area for more than 20 years and have a very good reputation with the local people. Apart from arranging funds for the businesses with help from Rang De, SAGRAS also arranges mentoring sessions that train the women in business basics. Now thats a real change from all the controversial micro credit firms that have recently been in the spotlight. It great to know that Rang De associates itself with organisations like SAGRAS. As we started our long journey back home, we had a lot of thoughts to discuss & experiences to share. I seemed to have met more entrepreneurs in a day than in my entire life ! This field trip had once again reminded us how a small gesture from our side can make a world of a difference to someones life. And Rang De was doing the job of connecting us to these deserving folk. Keep it up Rang De.
Friday, November 26, 2010 | 0 Comments
Adding custom LocatorBuilders to selenium ide
Background : Selenium is an open source tool for web application testing.
Selenium IDE is a Firefox plugin allows you to record tests in browser and run them from the browser or as a java test ( or any other languages ) using Selenium Remote Control libraries.
You can extend functionality of Selenium IDE by writing Event Handlers, Locator Builders, Command Builders, Custom Format all in JavaScript.
For more about that http://wiki.openqa.org/display/SIDE/Writing+extensions.
More on Locator Builders
Locator Builders decide how HTML elements in a page are identified.
eg id attribute is a default locator builder.
So while recording a test an html element attribute selenium using the id attribute to recognize the element you changed, clicked etc.
Writing a new locator builder
You can instruct selenium to use a custom attribute to identify the elements in your page. Default Locator builders can be found at chrome://selenium-ide/content/locatorBuilders.js
Here's the js code to add a location builder for an attribute myattr
LocatorBuilders.add('myattr', function(e) {
if (e.hasAttribute('myattr')) {
if (e.getAttribute("myattr")) {
return '//' + e.nodeName + '[@myattr=\'' +
e.getAttribute("myattr") + '\']';
}
}
return null;
});
Since there are plenty of existing location builders, you need to specify the order in which they are invoked. This is how its done
LocatorBuilders.order = ['myattr','id', 'link', 'name', 'dom:name',
'xpath:link','xpath:img', 'xpath:attributes', 'xpath:href',
'dom:index', 'xpath:position'];
Complete code: mylocator.js
LocatorBuilders.add('myattr', function(e) {
if (e.hasAttribute('myattr')) {
if (e.getAttribute("myattr")) {
return '//' + e.nodeName + '[@myattr=\'' +
e.getAttribute("myattr") + '\']';
}
}
return null;
});
LocatorBuilders.order = ['myattr','id', 'link', 'name', 'dom:name',
'xpath:link','xpath:img', 'xpath:attributes', 'xpath:href',
'dom:index', 'xpath:position'];
Steps to add the extension code to selenium IDE
- Write locator code in a new .js file
- Specify the path in "Selenium IDE extensions" field in Selenium IDE > Options and restart selenium IDE
Sunday, November 15, 2009 | 2 Comments