About phptuts

Author Archive | phptuts
PHP: How to check if the vertices of polygon are in clockwise or counter-clockwise order?

PHP: How to check if the vertices of polygon are in clockwise or counter-clockwise order?

How to check if the vertices of polygon are in clockwise or counter-clockwise order? There are many of method to check this. We offer some method below: Method 1: Use ComputeArea function: Method 2: Note: It is assumed that the polygon is simple (does not intersect itself or have holes) Example: Result: int(-1)

Read full story Comments { 0 }
PHP: How to calculate signed area of a Polygon

PHP: How to calculate signed area of a Polygon

Calculating the signed area for an polygon can be found when you know the coordinates of the vertices. We offer 3 methods below: Method 1: Method 2: Method 3: Method 4: Note: If you list the points in a clockwise order instead of counterclockwise, you will get the negative of the area. Hence this can […]

Read full story Comments { 0 }
How to install mytop

How to install mytop

mytop is a ‘top’ clone for MySQL. mytop is a console-based (non-gui) tool for monitoring the threads and overall performance of MySQL 3.22.x, 3.23.x, and 4.x servers. It runs on most Unix systems which have Perl, DBI, and Term::ReadKey installed. And with Term::ANSIColor installed you even get color. As of version 0.7, it even runs […]

Read full story Comments { 0 }

LXAdmin: Change the LXAdmin password

If you’ve forgotten your LXAdmin ‘admin’ password, you can change it by taking the following steps: 1. Connect to your VPS via ssh: Use Bitvise Tunnelier to login your VPS or dedicated server 2. Open new terminal console: 3. Run the following command. sh /script/resetpassword master newpassword Now you can use the new password to […]

Read full story Comments { 0 }
Google Maps JavaScript API v3: method Polygon.getBounds

Google Maps JavaScript API v3: method Polygon.getBounds

In Google Maps JavaScript API v2, Polygon had a getBounds() method, but that doesn’t exist for v3 Polygon. Here’s the solution: Here, we present a simplified method: Image copyright: Google maps

Read full story Comments { 0 }
Google Maps JavaScript API v3: method Polyline.getBounds

Google Maps JavaScript API v3: method Polyline.getBounds

In Google Maps JavaScript API v2, Polyline had a getBounds() method, but that doesn’t exist for v3 Polyline. I wrote some methods below: Method 1: Method 2: Method 3 is the shortest method. Image copyright: Google Maps

Read full story Comments { 0 }
PHP: detect Point in Polygon

PHP: detect Point in Polygon

PHP function to detect Point in Polygon: Test for convex polygon: Result: IN OUT Test for concave polygon: Result: OUT IN OUT Note: we only apply this method for simple polygon (non-self-intersecting polygon). Test for complex polygon (self-intersecting polygon) Result: OUT OUT OUT Error for point 2.

Read full story Comments { 0 }
PHP: Calculate Distance Between Two Coordinates

PHP: Calculate Distance Between Two Coordinates

This routine calculates the distance between two points (given the latitude/longitude of those points). It is being used to calculate the distance between two locations: Example: Result: 434916.310601 Note: Result as meters Ellipsoidal parameters: Name Major axis, a (km) Flattening (f) WGS84 6378.13700 1/298.257223563 GRS80/NAD83 6378.13700 1/298.257222101 WGS66 6378.145 1/298.25 GRS67/IAU68 6378.16000 1/298.2472 WGS72 6378.135 […]

Read full story Comments { 0 }

PHP: convert javascript escape string to CP1251

This function can convert javascript escape string to CP1251: Example 2: result: ຈະນານຸກົມພິເສດ Read more: PHP: convert javascript escape string to UTF8

Read full story Comments { 0 }
PHP: convert javascript escape string to UTF8

PHP: convert javascript escape string to UTF8

Read first: PHP: PHP: Convert Numeric Character Reference to UTF8 Example 1: U+0621: ARABIC LETTER HAMZA Java Escape: “\u0621” Javascript Escape: “\u0621” result: ء We can create this function below: Example 2: result: สารานุกรมเสรี Alternative function:

Read full story Comments { 0 }