Category Archives: project

GMap.NET component : Moving Marker

WTH is GMap.NET?

Simply put: it’s an open source .net component that can show online mapping service (such as Google Map, Bing Map, OpenStreetMap) in your .NET app.
Download the binary here: http://greatmaps.codeplex.com/
Extract it. You’ll get the .net 2.0 and .net 4.0 version, since I’m using VS 2015, we’ll use the .net 4.0 version.

What will we do now is about how to move a marker inside the map (for tracking/visualizing object movement, etc). We’ll just move the marker randomly in this tutorial.

  • Create new VB Windows Form project
  • Add GMap.NET component into your project reference
GMap.NET component reference

GMap.NET component reference

  • Add GMap.NET component into your toolbar.
Add GMap.NET component step 1

Add GMap.NET component step 1

Add GMap.NET component step 2

Add GMap.NET component step 2

  • Now drag and drop the GMap.NET control into your Form, I name it myMap
  • We’ll also add another controls: 1 Button (name: btnMove), 1 Timer (name: tmr1), 1 Label (name: lblInfo)
List of components

List of components

I also add new bitmap resource into our project properties. This will be used as our marker symbol.

Resource for marker symbol

Resource for marker symbol

You can see the Form’s full source code at the bottom of this post. I’ll just point out some important parts:

  • Map initialization is on Form1_Load event code (zoom level, initial position, provider used, marker type, etc)
  • When you click on the btnMove, it’ll start generating new random position for our marker. The random change is happened in the timer event (tmr1_Tick)
  • The process to update the map visual is delegated into function update_map(), so it will run in different thread and the form still responsive
  • In this tutorial, we are using BingSatelliteMapProvider, you can use another provider such as GoogleMapProvider or OviSatelliteMapProvider. Just see MapProviders namespace to see all supported providers.

Running the app

Running the app


Here’s the full source code:

Exporting high resolution image from QGIS project

qgis_hasil_resolusi

Problem:

You want to export your QGIS project into high resolution image. QGIS desktop “Project” –> “Save as Image” only save/export the project into a low resolution image (i.e. your desktop resolution).

qgis_banyumanik

Solution:

1. Finish your project in QGIS

Finish your GIS project in QGIS Desktop, choose which layers to be shown, what style should it use, etc.

2. Choose your extent that will be exported into image

For myself, I choose the full-extent, but you may choose the extent as you wish. You my use “Vector” –> “Coordinate Capture” to help copying the coordinates. You will need to write down the coordinates for [xMin, yMin] (top-left coordinate) and for [xMax, yMax] (bottom-right coordinate). Save and close your QGIS project.

3. Execute the export command via command line of QGIS

Open your command prompt/console (preferably as Administrator/root). Go to your QGIS binary folder, where you install QGIS +”bin” folder, for example C:\Program Files\QGIS Brighton\bin. Use this command template:

For example:

That command will open QGIS Desktop for a moment then close itself. The command will produce padangsari.png in c:\users\achmadz\documents\. Open the image, and you’ll see the image in high resolution (5000×5000 pixels).

qgis_hasil_resolusi

[php] New Bing SERP checker using Windows Azure Datamarket

So, I got email from Bing Developer Team informing that Bing Search API 2.0 will be gone and moving to new platform: Windows Azure Datamarket. On my previous Bing SERP checker project, I’m using Bing Search API 2.0 which means that those codes will no longer working after 1st August.

Windows Azure Datamarket provide a trial package and a free package that has limit for 5000 requests per month. More than enough for us to toying for Bing SERP checker.

Go get your Account Key (was Application ID) : https://datamarket.azure.com/

This is the revised main function php codes so it will work on new Windows Azure Datamarket web service

How you call it:

Example output:

Fully working demo: http://demo.ahowto.net/new_bserp/

Actually, there are a lot of other “Search Market” that supported by Bing but I only listed some of them just for example. Download this document for complete list of Bing’s supported Search Market: http://www.bing.com/webmaster/content/developers/ADM_SCHEMA_GUIDE.docx

Notes:

  1. Your PHP version must be PHP 5.2 or higher (because of json_decode command)
  2. You must activate PHP OpenSSL module (php_openssl) because we are using file_get_contents and the webservice end point must be accessed via HTTPS

Update (2012-07-20) : the endpoint URL is changed

[php] Simple captcha alternative — using math question

Today, I received some task to implement some kind of captcha in some forms in hope that this captcha will reduce the garbage and automated submission. The client asked me to implement some user friendly captcha not those that hard to see. Re-Captcha and image based captcha (such as that I implemented in mp3 to Youtube‘s contact form) is not an option. Finally, the client decided to use captcha that ask visitors some simple math problem, i.e. addition and subtraction.

I remember that one of wordpress plugin had this kind of feature. I think it’s Contact Form 7. Oh, it’s actually Really Simple Captcha plugin. But there’s another huge problem. The website is not even a wordpress-based blog/site, it’s just simple site, probably created from ground-up using Dreamweaver. So, once again, installing a plugin is not an option.

After analyzing the requirements, I decided to create it myself. This is the simple captcha features that I created:

  • it use PHP session
  • the question is just a simple math addition or subtraction. No hard to see words or image
  • the number in the math problem is small (1 – 10), 4th grader would be easily solve the math problem
  • easily added to any existing PHP forms
  • works for PHP (non-CMS) based site.

The main code is saved in file named “scaptcha.php“. This is the full source codes:

Explanation:

First, it will start PHP session. $sentence array is used to store the sentences that will be seen by visitors before the math problem. You can edit it as you wish. $operands array is the math operand supported by this simple captcha script. The script then choose which sentence to be shown and the math operand randomly. Next, it will randomly choose 2 numbers between 1 and 10, operate it mathematically then store the result in PHP session.

The form that want to use this simple captcha have to include the file above (scaptcha.php).

Then, inside a form HTML element and –usually– exactly before form Submit button, these codes must be placed:

As you can see, the script simply show the random sentence, both numbers and operand to users then create a new text- type input where user can put it’s answer. The input text is named “answer“, you can change this if it’s already used in different form’s element name.

The target file (where the POST variables from the current form is sent and processed) must use session_start()in order to “catch” the “correct answer” of the simple captcha. Then compare the value between the correct answer saved in session and the user/visitor answer. If the answer is the same, then continue processing the form, if not, then show an error messages:

You have to match the $_POST[‘answer’] with the input text form’s element name generated by the script inside the previous form (only if you changed it to other names than ‘answer‘).

Full working demo can be tested here: http://demo.ahowto.net/scaptcha/

Simple SOCKS5 proxy checker

OK, found another small project from old blog. I’ve created small PHP script to check whether a SOCKS5 proxy server is alive or not.

Full source code here (can’t write in this post because the source code is mixed with HTML codes): http://demo.ahowto.net/socks5check.phps

Fully working demo URL: http://demo.ahowto.net/socks5check.php

simple socks5 checker result

Where to get SOCKS5 proxy list for FREE?

Remember that the script is only working for SOCKS version 5, not 4