Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
inerba committed Nov 21, 2023
0 parents commit 52173d7
Show file tree
Hide file tree
Showing 44 changed files with 5,955 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
28 changes: 28 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore all test and documentation with "export-ignore".
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.idea export-ignore
/.prettierrc export-ignore
/.package-lock.json export-ignore
/.editorconfig export-ignore
/.php_cs.dist.php export-ignore
/.vscode export-ignore
/art export-ignore
/docs export-ignore
/images export-ignore
/tests export-ignore
/package.json export-ignore
/phpstan-baseline.neon export-ignore
/phpstan.neon.dist export-ignore
/postcss.config.js export-ignore
/phpunit.xml.dist export-ignore
/pint.json export-ignore
/psalm.xml export-ignore
/psalm.xml.dist export-ignore
/tailwind.config.js export-ignore
/testbench.yaml export-ignore
/UPGRADING.md export-ignore
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.DS_Store
.idea
.phpunit.result.cache
.vscode
build
composer.lock
coverage
docs
node_modules
phpunit.xml
phpstan.neon
testbench.yaml
vendor
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "all"
}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

All notable changes to `gis-tools` will be documented in this file.

## 1.0.0 - 202X-XX-XX

- initial release
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) postare <inerba@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
101 changes: 101 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# This is my package gis-tools

[![Latest Version on Packagist](https://img.shields.io/packagist/v/postare/gis-tools.svg?style=flat-square)](https://packagist.org/packages/postare/gis-tools)
[![Total Downloads](https://img.shields.io/packagist/dt/postare/gis-tools.svg?style=flat-square)](https://packagist.org/packages/postare/gis-tools)

Gis Tools is a highly customizable plugin for FilamentPHP, designed to simplify map and GIS functionality management
within your web application. With Gis Tools, you can effortlessly integrate interactive maps, analyze geospatial data,
and enhance the user experience with advanced GIS features.

The system harnesses the power of [Leaflet](https://leafletjs.com/) to provide interactive maps and relies on the
[Laravel Eloquent Spatial](https://github.com/MatanYadaev/laravel-eloquent-spatial) package to simplify
the handling of spatial data.

To gain a comprehensive understanding of how to make the most of `matanyadaev/laravel-eloquent-spatial`, we highly
recommend referring to its official documentation.

## Installation

You can install the package via composer:

```bash
composer require postare/gis-tools
```

Make sure to publish the assets to ensure that the default icons can be displayed correctly:

```bash
php artisan vendor:publish --tag="gis-tools-assets"
```

## Map Field

This plugin provides a map field for all forms, enriching your applications with advanced geospatial capabilities. Its
key features include:

- The ability to select a point on the map using a draggable marker, making map interaction an intuitive experience.
- The option to use one or more map tiles of your choice, ensuring flexibility in map visualization.
- Complete marker customization to seamlessly match your application's design.
- Easy input of geographic coordinates, simplifying location data management.

### Usage

Inside a form schema, you can use the Map input like this:

```php
use Postare\GisTools\Forms\Components\Map;

Map::make('location')
->height(500) // Map height in pixels
->showCoordinates() // Show an overlay with the coordinates of the point

// To set the starting point
->default([
'type' => 'Point',
'coordinates' => [
41.72, // longitude
13.34, // latitude
],
])

// To specify the tiles to use
// If not specified, it will use OpenStreetMap; otherwise, you can choose one or more tiles.
// Here's a list: https://leaflet-extras.github.io/leaflet-providers/preview/
->tiles([
[
'name' => 'OpenStreetMap',
'url' => 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
'options' => [
'maxZoom' => 19,
'attribution' => 'Map data: &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors',
],
],
[
'name' => 'OpenTopoMap',
'url' => 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',
'options' => [
'maxZoom' => 17,
'attribution' => 'Map data: &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, <a href="http://viewfinderpanoramas.org">SRTM</a> | Map style: &copy; <a href="https://opentopomap.org">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>)',
],
],
[
'name' => 'Esri World Imagery',
'url' => 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
'options' => [
'attribution' => '&copy; ESRI',
],
]
])

// To specify the marker icon, otherwise the default one will be used
->markerIcon([
'iconUrl' => 'https://mapmarker.io/api/v3/font-awesome/v6/pin?icon=fa-solid%20fa-star&size=60&color=FFF&background=990099&hoffset=0&voffset=0',
'iconSize' => [60, 60],
'iconAnchor' => [30, 60],
])
->required(),
````

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
51 changes: 51 additions & 0 deletions bin/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import esbuild from 'esbuild'

const isDev = process.argv.includes('--dev')

async function compile(options) {
const context = await esbuild.context(options)

if (isDev) {
await context.watch()
} else {
await context.rebuild()
await context.dispose()
}
}

const defaultOptions = {
define: {
'process.env.NODE_ENV': isDev ? `'development'` : `'production'`,
},
bundle: true,
mainFields: ['module', 'main'],
platform: 'neutral',
sourcemap: isDev ? 'inline' : false,
sourcesContent: isDev,
treeShaking: true,
target: ['es2020'],
minify: !isDev,
plugins: [{
name: 'watchPlugin',
setup: function (build) {
build.onStart(() => {
console.log(`Build started at ${new Date(Date.now()).toLocaleTimeString()}: ${build.initialOptions.outfile}`)
})

build.onEnd((result) => {
if (result.errors.length > 0) {
console.log(`Build failed at ${new Date(Date.now()).toLocaleTimeString()}: ${build.initialOptions.outfile}`, result.errors)
} else {
console.log(`Build finished at ${new Date(Date.now()).toLocaleTimeString()}: ${build.initialOptions.outfile}`)
}
})
}
}],
}

compile({
...defaultOptions,
entryPoints: ['./resources/js/components/map-component.js'],
outfile: './resources/dist/components/map-component.js',
// outdir: './resources/dist',
})
71 changes: 71 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"name": "postare/gis-tools",
"description": "This is my package gis-tools",
"keywords": [
"postare",
"laravel",
"gis-tools"
],
"homepage": "https://github.com/postare/gis-tools",
"support": {
"issues": "https://github.com/postare/gis-tools/issues",
"source": "https://github.com/postare/gis-tools"
},
"license": "MIT",
"authors": [
{
"name": "Francesco",
"email": "inerba@gmail.com",
"role": "Developer"
}
],
"require": {
"php": "^8.1",
"filament/filament": "^3.0",
"illuminate/contracts": "^10.0",
"matanyadaev/laravel-eloquent-spatial": "^3.2",
"spatie/laravel-package-tools": "^1.15.0"
},
"require-dev": {
"nunomaduro/collision": "^7.9",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.0",
"pestphp/pest-plugin-arch": "^2.0",
"pestphp/pest-plugin-laravel": "^2.0"
},
"autoload": {
"psr-4": {
"Postare\\GisTools\\": "src/",
"Postare\\GisTools\\Database\\Factories\\": "database/factories/"
}
},
"autoload-dev": {
"psr-4": {
"Postare\\GisTools\\Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"phpstan/extension-installer": true
}
},
"extra": {
"laravel": {
"providers": [
"Postare\\GisTools\\GisToolsServiceProvider"
],
"aliases": {
"GisTools": "Postare\\GisTools\\Facades\\GisTools"
}
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
6 changes: 6 additions & 0 deletions config/gis-tools.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

// config for Postare/GisTools
return [

];
19 changes: 19 additions & 0 deletions database/factories/ModelFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Postare\GisTools\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/*
class ModelFactory extends Factory
{
protected $model = YourModel::class;
public function definition()
{
return [
];
}
}
*/
19 changes: 19 additions & 0 deletions database/migrations/create_gis_tools_table.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up()
{
Schema::create('gis_tools_table', function (Blueprint $table) {
$table->id();

// add fields

$table->timestamps();
});
}
};
Loading

0 comments on commit 52173d7

Please sign in to comment.