I successfully installed tile server based on the instruction given in the switch2osm.org/serving-tiles/manually-building-a-tile-server-14-04/. So I have well-working web-server + tile-server. But there are no housenumbers on map. I add my next code in my imposm-mapping.py
buildings = Polygons (
name = 'buildings',
fields = (
('area', PseudoArea()),
('addr:housenumber', String()),
),
mapping = {
'building': (
'__any__',
),
'railway': (
'station',
)
'aeroway': (
'terminal',
),
}
)
In my labels.mss I have:
#housenumber [zoom>=17]{
::label {
text-name: '[addr:housenumber]';
text-face-name:#sans;
text-size: 9;
text-placement: interior;
text-min-dostance: 1;
text-wrap-width: 0;
text-fill: #444;
}
}
In default.style I have node,way addr:housenumber text linear.
I saw question Map won't show building numbers (tileMill + OSM). But I don't understand this tips.
Well, problem solved. I just reload data to database with carto.style, rebuild tile server with swich2osm instructions but with stylesheet from openstreetmap-carto. Not OSMBright
Related
I implemented a dag with a task_group that loops on the contents of a file.. This isn't ideal, I wish I could loop through the contents of an XCom, unless I'm mistaken, that isn't possible.
import json
import logging
from airflow.decorators import task_group
from airflow.operators.dummy import DummyOperator
from dtm.migration.helpers.tasks import (
check_compliance_of_objects_sizes,
)
from airflow.providers.google.cloud.transfers.gcs_to_gcs import GCSToGCSOperator
from airflow.providers.google.cloud.sensors.gcs import (
GCSObjectExistenceSensor,
)
#task_group(group_id="copy_task_group")
def copy_and_verify(
inp_parameters_path: str,
impersonated_service_account: str,
):
try:
with open(inp_parameters_path, "r") as f:
inp_parameters = json.load(f)
for entry in inp_parameters:
sensor_source_file = GCSObjectExistenceSensor(
task_id=f"sensor_source_file_{entry}",
bucket=inp_parameters[entry]["source"]["bucket"],
object=(
f"{inp_parameters[entry]['source']['prefix']}"
f"/{inp_parameters[entry]['source']['object']}"
),
impersonation_chain=impersonated_service_account,
)
copy_file = GCSToGCSOperator(
task_id=f"copy_file_{entry}",
source_bucket=inp_parameters[entry]["source"]["bucket"],
source_object=(
f"{inp_parameters[entry]['source']['prefix']}"
f"/{inp_parameters[entry]['source']['object']}"
),
destination_bucket=inp_parameters[entry]["destination"][
"bucket"
],
destination_object=(
f"{inp_parameters[entry]['destination']['prefix']}"
f"/{inp_parameters[entry]['destination']['object']}"
),
impersonation_chain=impersonated_service_account,
)
check_size = check_compliance_of_objects_sizes(
date_of_execution="{{ds_nodash}}",
data_to_check=inp_parameters[entry],
impersonation_chain=impersonated_service_account,
)
sensor_destination_file = GCSObjectExistenceSensor(
task_id=f"sensor_destination_file_{entry}",
bucket=inp_parameters[entry]["destination"]["bucket"],
object=(
f"{inp_parameters[entry]['destination']['prefix']}"
f"/{inp_parameters[entry]['destination']['object']}"
),
impersonation_chain=impersonated_service_account,
)
end_op = DummyOperator(task_id=f"end_{entry}")
(
sensor_source_file
>> copy_file
>> check_size
>> sensor_destination_file
>> end_op
)
except FileNotFoundError:
logging.info(
f"File {inp_parameters_path} is generated in a prior task."
)
As you can see, I used try...except FileNotFoundError: because the error (file not found) is raised on the dag creation since the inp_parameters_path hadn't been created yet by the upstream tasks.
The inp_parameters_path is a file that is created upstream, but unfortunately, it seems that in order to display the logged steps of the task_group post execution I need to keep this file.. Which I don't because it will change from one day to another.
Example of removal of task_group contents after execution:
The contents were well present before the remove_mapping_file has run.
How to pass an XCom to a task_group the same way I can do it with a task? If that's not possible, how do I archive those created inp_parameters_path files per execution so that I can come back and browse the execution of the dag?
If it can help, here's how my dag operates :
#dag(
catchup=False,
schedule_interval="#daily",
max_active_runs=1,
dag_id="migrate_dtm_gcs_data_history",
start_date=datetime(2022, 12, 1),
dagrun_timeout=timedelta(minutes=20),
tags=[
"migration",
"dtm",
],
default_args=default_args,
)
def template_dag():
map = convert_csv_migration_to_map(
source_csv=f"{COMPOSER_GCS_LOC_PATH}/dags/dtm/migration/helpers/gcs_migration_mapping_archetype.csv",
delimiter=",",
)
updated_map_1 = update_mapping_with_gcp_project_and_buckets_ids(
src_mig_map=map,
env="dev",
impersonation_chain=IMPERSONATED_SERVICE_ACCOUNT,
)
list_files_and_prefixes = GCSListObjectsOperator(
task_id="list_files_and_prefixes",
bucket=LEGACY_DTM_HISTORY_BUCKET,
prefix="raw_data/datamart/{{ds_nodash}}",
impersonation_chain=IMPERSONATED_SERVICE_ACCOUNT,
)
updated_map_2 = match_data_with_migration_map(
src_mig_map=updated_map_1,
files_and_prefixes=list_files_and_prefixes.output,
)
list_of_maps = flatten_to_input_files_granularity(
src_mig_map=updated_map_2,
)
gcs_migration_maps_path = (
f"{COMPOSER_GCS_LOC_PATH}/dags/dtm/migration"
f"/helpers/gcs_migration_list_of_maps_{{ds_nodash}}.json"
)
write_list_of_maps_into_dict = gen_dict_file_from_list_of_map(
file_name=gcs_migration_maps_path,
list_of_maps=list_of_maps,
)
copy_task_group = copy_and_verify(
inp_parameters_path=gcs_migration_maps_path,
impersonated_service_account=IMPERSONATED_SERVICE_ACCOUNT,
)
remove_mapping_file = BashOperator(
task_id="remove_mapping_file",
bash_command=f"rm -vf {gcs_migration_maps_path}",
)
(
map
>> updated_map_1
>> list_files_and_prefixes
>> updated_map_2
>> list_of_maps
>> write_list_of_maps_into_dict
>> copy_task_group
>> remove_mapping_file
)
dag = template_dag()
The description for replaceField SMT says it can Filter or rename fields within a Struct or Map. However I can't find any working example for replacing or renaming fields within a struct.
I've got data in a topic being written into ElasticSearch using Kafka Connect Elasticsearch Sink. For simplicity, assume the format of the data looks like this.
{
'ID':22,
'ITEM': 'Shampoo'
'USER':{
'NAME': 'jon',
'AGE':25
}
}
So if I'm trying to rename/replace USER.NAME or USER.AGE, how would I configure that in the connector? (I've written everything in ksqldb). This is my current config where I rename ITEM to product and ID to id
CREATE SINK CONNECTOR ELASTIC_SINK WITH (
'connector.class' = 'io.confluent.connect.elasticsearch.ElasticsearchSinkConnector',
'connection.url' = 'http://host.docker.internal:9200',
'type.name' = '_doc',
'topics' = 'ELASTIC_TOPIC',
'key.ignore' = 'false',
'schema.ignore' = 'true',
'transforms' = 'RenameField',
'transforms.RenameField.type' = 'org.apache.kafka.connect.transforms.ReplaceField$Value',
'transforms.RenameField.renames' = 'ITEM:product,ID:id',
);
Take a look at the existing SO question and answer: https://stackoverflow.com/a/56601093/4778022
You can provide the path to the field to rename, with parts separated by periods.
CREATE SINK CONNECTOR ELASTIC_SINK WITH (
'connector.class' = 'io.confluent.connect.elasticsearch.ElasticsearchSinkConnector',
'connection.url' = 'http://host.docker.internal:9200',
'type.name' = '_doc',
'topics' = 'ELASTIC_TOPIC',
'key.ignore' = 'false',
'schema.ignore' = 'true',
'transforms' = 'RenameField',
'transforms.RenameField.type' = 'org.apache.kafka.connect.transforms.ReplaceField$Value',
'transforms.RenameField.renames' = 'USER.NAME:name,ITEM:product,ID:id',
);
I am making my very first wordpress plugin in that I want to make table in my database when I activate the plugin. I write the code exactly what wordpress community said but it's not working. I tried the same several times but the results is the same. I also want to know my plugin showing 2 submenus in my main plugin menu, It's like
My Plugin
-- My Plugin
-- My Submenu Page
Please help I am very new to plugin development.
// Registering plugin
register_activation_hook(__FILE__, 'myplugin_activate');
//Deactivate plugin
register_deactivation_hook(__FILE__, 'myplugin_deactivate');
function myplugin_activate() {
global $wpdb, $table_prefix;
global $favoritethis_db_version;
$table_name = $table_prefix.
'my-plugin-table';
$charset_collate = $wpdb - > get_charset_collate();
if ($wpdb - > get_var("show tables like '$table_name'") != $table_name) {
require_once(ABSPATH.
'wp-admin/upgrade-functions.php');
$sql = "CREATE TABLE ".$table_name.
" (
id mediumint(9) NOT NULL AUTO_INCREMENT,
time datetime DEFAULT '0000-00-00 00:00:00'
NOT NULL,
name tinytext NOT NULL,
text text NOT NULL,
url varchar(55) DEFAULT ''
NOT NULL,
UNIQUE KEY id(id)
) $charset_collate;
";
}
require_once(ABSPATH.
'wp-admin/includes/upgrade.php');
dbDelta($sql);
}
function myplugin_deactivate() {
// Deactivation code here...
echo "<script>alert('Ohhh.. no baby the plugin is deactivated now..')</script>";
}
also I found the solution of the problem, I was facing as getting extra sub menu as same name as the main menu is.
Solution
//Main admin menus
add_action('admin_menu', 'add_my_custom_menu');
function add_my_custom_menu() {
//add an item to the menu
add_menu_page(
'My Plugin',
'My Plugin',
10,
plugin_dir_path(__FILE__).
'admin/plugin-form.php',
'',
plugin_dir_url(__FILE__).
'img/contact.png'
);
add_submenu_page(
'my-plugin-name/admin/plugin-form.php',
'Plugin Setting',
'Plugin Setting',
10,
plugin_dir_path(__FILE__).
'admin/plugin-form.php',
'myplugin_options_page'
);
add_submenu_page(
'my-plugin-name/admin/plugin-form.php',
'Plugin Entries',
'Plugin Entries',
10,
plugin_dir_path(__FILE__).
'admin/entries.php',
''
);
}
reason is that every first sub-menu's destination page/function will be the same as main menu destination.
ok I got the answer myself
// Registering plugin
register_activation_hook(__FILE__, 'myplugin_activate');
//Deactivate plugin
register_deactivation_hook(__FILE__, 'myplugin_deactivate');
function myplugin_activate() {
global $wpdb;
$table_name = $wpdb - > prefix.
'my-plugin-table';
//nstalled_ver = get_option('my-voting-version');
if ($wpdb - > get_var("show tables like '$table_name' ") != $table_name) {
require_once(ABSPATH.
'wp-admin/upgrade-functions.php');
$sql = "CREATE TABLE IF NOT EXISTS `".str_replace('`', '', $table_name).
"` (
id mediumint(9) NOT NULL AUTO_INCREMENT,
time datetime DEFAULT '0000-00-00 00:00:00'
NOT NULL,
name tinytext NOT NULL,
text text NOT NULL,
url varchar(55) DEFAULT ''
NOT NULL,
UNIQUE KEY id(id)
);
";
}
require_once(ABSPATH.
'wp-admin/includes/upgrade.php');
dbDelta($sql);
}
I have the following little piece of code (more less as described HERE) - I want to control the number of points to be shown by a slider in shiny. You can see that the initial map is loaded after a little while (watch console output), but it will only show up after you used the slider once.
But I'd like the map to show up after it is created during launch of the shiny app - any hints how to do that?
## app.R ##
library(shiny)
library(shinydashboard)
library(httr)
library(leafletR)
data(quakes)
# dest_dir=tempdir()
dest_dir="foo_map"
dest_file = paste(dest_dir,"quakes","quakes.html",sep="\\")
dat = quakes
createMapHTML <- function(inputFreq=1) {
q.dat <- toGeoJSON(data=dat[seq(from = 1, to = nrow(dat), by=inputFreq), ],
dest=dest_dir, name="quakes")
sty <- styleSingle(col="darkblue", fill="darkblue", rad=6)
# create map
q.map <- leaflet(data=q.dat, dest=dest_dir, size = c(1200, 600), incl.data=TRUE,
base.map=list("osm"), style=sty, popup="*", controls="all")
}
# createMapHTML()
runApp(list(
ui = dashboardPage(
dashboardHeader(title = "quakes"),
dashboardSidebar(
sliderInput("slider", "#observations frequency:", 1, 100, 1)
),
dashboardBody(
htmlOutput("inc")
)
),
server = function(input, output, session) {
createMap <- reactive({
createMapHTML(input$slider)
return(includeHTML(dest_file))
})
output$inc<-renderUI({ createMap() })
}
))
so the bottleneck with the leafletR package is the conversion to GeoJson. Additionally the "includeHTML & htmlOutput" workaround for embedding the html out is flaky..
To avoid both I just switched to the leaflet packackage:
## app.R ##
library(shiny)
library(shinydashboard)
library(leaflet)
data(quakes)
dat = quakes
runApp(list(
ui = dashboardPage(
dashboardHeader(title = "quakes"),
dashboardSidebar(
sliderInput("slider", "#observations frequency:", 1, 100, 1)
),
dashboardBody(
leafletOutput("map", height = 600)
)
),
server = function(input, output) {
output$map <- renderLeaflet({
map <- leaflet() %>% addTiles()
map %>% addCircles(data=dat[seq(from = 1, to = nrow(dat), by=input$slider), ], #input$slider
lat = ~lat, lng = ~long, fillOpacity = 1.0)
})
}
))
So here's the situation:
-I have a forum software, XenForo for customers to frolick about in
-I have a membership software, aMember, to handle customer payments and deliver digital products. (Both on the same website)
aMember has a template system that allows you to (ideally) easily customize the script to look like it's naturally part of your website.
XenForo has a script addon that lets you use the customized XenForo Header and footer using a PHP "include" function.
So essentially, I can take a regular php file, call the XenForo header and footer using php include, and make that page look like it's part of the forum software (almost like a wordpress header/footer). So far, everything I've mentioned is tested and working outside the aMember system, so I currently have an index.php file that calls the XenForo header and footer using include and it works great.
Here's where it gets nasty, I tried to use the PHP include script inside the aMember template system. I got it mostly working, but then the following Error is thrown with the resulting fun batch of code afterwards:
Error: Registry is already initialized
Exception Zend_Exception
Zend_Registry::setClassName [ /home/content/p/p/o/ppowers/html/forum/library/XenForo/Application.php : 244 ]
XenForo_Application::initialize [ /home/content/p/p/o/ppowers/html/forum/library/Dark/Kotomi/KotomiHeader.php : 5 ]
include_once [ /home/content/p/p/o/ppowers/html/header.php : 6 ]
include_once [ library/Am/View.php : 419 ]
Am_View->printLayoutHead [ application/default/themes/sample/layout.phtml : 8 ]
include [ library/Am/View.php : 352 ]
Am_View->_run [ library/Zend/View/Abstract.php : 888 ]
Zend_View_Abstract->render [ library/Am/View.php : 326 ]
Am_View->display [ application/default/controllers/IndexController.php : 7 ]
IndexController->indexAction [ library/Am/Controller.php : 139 ]
Am_Controller->_runAction [ library/Am/Controller.php : 116 ]
Am_Controller->dispatch [ library/Zend/Controller/Dispatcher/Standard.php : 295 ]
Zend_Controller_Dispatcher_Standard->dispatch [ library/Zend/Controller/Front.php : 954 ]
Zend_Controller_Front->dispatch [ library/Am/App.php : 1372 ]
Am_App->run [ index.php : 41 ]
From what I can tell and my limited programming knowledge, it looks like aMember and XenForo are having a fight over who gets to use the Zend Registry.
Is there anyway I can make them play well together without hiring a full time programmer for 6 months? Thanks so much!
........................................................Response to comment:
The add comment didn't have enough charecters, so here's some of the code.
From what I can tell XenForo uses it as it's primary..well...everything, here's the START of Application.php, part of XenForo's source code. This file is over 1,000 lines, all of which make up the class that start's at the top... This seems to be the only file that uses the Zend_Registry that isn't part of the Zend source itself.
class XenForo_Application extends Zend_Registry
{
const URL_ID_DELIMITER = '.';
public static $version = '1.1.0';
public static $versionId = 1010070; // abbccde = a.b.c d (alpha: 1, beta: 3, RC: 5, stable: 7, PL: 9) e
public static $jsVersion = '';
public static $jQueryVersion = '1.5.2';
protected $_configDir = '.';
protected $_rootDir = '.';
protected $_initialized = false;
protected $_lazyLoaders = array();
protected static $_handlePhpError = true;
protected static $_debug;
protected static $_randomData = '';
protected static $_classCache = array();
public static $time = 0;
public static $host = 'localhost';
aMember uses it across several files, here are a few examples:
This is inside form.php...
public function findRuleMessage(HTML_QuickForm2_Rule $rule, HTML_QuickForm2_Node $el)
{
$strings = array(
'rule.required' => ___('This is a required field'),
);
$type = lcfirst(preg_replace('/^.+rule_/i', '', get_class($rule)));
$tr = Zend_Registry::get('Zend_Translate');
$fuzzy = sprintf('rule.%s', $type);
if (array_key_exists($fuzzy, $strings))
return $strings[$fuzzy];
}
And this is inside app.php....
function amDate($string) {
if ($string == null) return '';
return date(Zend_Registry::get('Am_Locale')->getDateFormat(), amstrtotime($string));
}
function amDatetime($string) {
if ($string == null) return '';
return date(Zend_Registry::get('Am_Locale')->getDateTimeFormat(), amstrtotime($string));
}
function amTime($string) {
if ($string == null) return '';
return date(Zend_Registry::get('Am_Locale')->getTimeFormat(), amstrtotime($string));
}
Alright, I better not post any more source code or they'll send the men in black after me.
It looks like it might be easier to program it out of aMember, but this is quickly looking like an insurmountable task, especially at my (lack of) skill level.
Additional Info:
public static function initialize($configDir = '.', $rootDir = '.', $loadDefaultData = true)
{
(244)self::setClassName(__CLASS__);
self::getInstance()->beginApplication($configDir, $rootDir, $loadDefaultData);
}
Commenting out Line 244 produced the following error:
Fatal error: Call to undefined method Zend_Registry::beginApplication() in /home/content/p/p/o/ppowers/html/forum/library/XenForo/Application.php on line 245
And adding the code you suggested into the aMember index.php file produced this error:
Fatal error: Class 'XenForo_Application' not found in /home/content/p/p/o/ppowers/html/amember/index.php on line 40
What is on line 244 of /home/content/p/p/o/ppowers/html/forum/library/XenForo/Application.php? If it's just Zend_Registry which is the default class name and if you are not afraid of modifying the sources, just comment out the call on line 244. But this is not advised as you would have problems if you wanted to update XenForo in the future.
Check if whatever is passed to setClassName() on line 244 can be configured somehow. Paste some more code. Get some more answers.
UPDATE
Fighting with XenForo would probably require quite a lot of coding, so I'd suggest a rather different approach. Since aMemeber seems to use vanilla Zend_Registry, you can try to make sure XenForo's extended version of Zend_Registry instantiates first. In your index.php (probably located in public directory) locate the line with $application->bootstrap(); or similar, and before this line add something like this:
XenForo_Application::setClassName("XenForo_Application");
And comment out line 244 of /home/content/p/p/o/ppowers/html/forum/library/XenForo/Application.php.
If this works, remember to comment on the change, cross-referencing both modified files.
I build my website I am using Zend framework v1.5: http://www.panpic.vn (**) |
Forum using xenforo: http://www.panpic.vn/forum (*)
at homepage (**) I am Authentication User Xenforo
My Coding:
define('XF_ROOT', '/home/www/lighttpd/my_web/forum'); // set this (absolute path)!
define('STARTTIME', microtime(true) );
define('SESSION_BYPASS', false); // if true: logged in user info and sessions are not needed
require_once(XF_ROOT . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader(XF_ROOT . '/library');
XenForo_Application::initialize(XF_ROOT . '/library', XF_ROOT);
XenForo_Application::set('page_start_time', STARTTIME );
XenForo_Application::setDebugMode(false);
if (!SESSION_BYPASS)
{
$dependencies = new XenForo_Dependencies_Public();
$dependencies->preLoadData();
$session = XenForo_Session::startPublicSession(new Zend_Controller_Request_Http);
XenForo_Visitor::setup($session->get('user_id'));
$visitor = XenForo_Visitor::getInstance();
if ($visitor->getUserId())
{
$userModel = XenForo_Model::create('XenForo_Model_User');
$userinfo = $userModel->getFullUserById($visitor->getUserId());
}
}
Error: Registry is already initialized
Could you how do I fix ?