You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public.ST_LineInterpolatePoint(public.ST_LineMerge(r.geom), random()) AS geom
229
229
FROM selected_roads a
@@ -235,13 +235,13 @@ END
235
235
$$
236
236
;
237
237
238
-
COMMENT ON PROCEDURE geo_faker.point_in_place_landuse IS 'Uses osm.landuse_polygon and osm.road_line to simulate probable locations for commercial store locations. Can be customized for custom landuse types by manually defining landuse_osm_types temp table.'
238
+
COMMENT ON PROCEDURE geofaker.point_in_place_landuse IS 'Uses osm.landuse_polygon and osm.road_line to simulate probable locations for commercial store locations. Can be customized for custom landuse types by manually defining landuse_osm_types temp table.'
COMMENT ON FUNCTION geo_faker.n_points_in_polygon(GEOMETRY, INT) IS 'Creates N points randomly within the given polygon.';
291
+
COMMENT ON FUNCTION geofaker.n_points_in_polygon(GEOMETRY, INT) IS 'Creates N points randomly within the given polygon.';
292
292
293
293
294
294
295
295
-- Call the procedure to ensure the required temp table exists, avoids deploy failure
296
-
CALL geo_faker.point_in_place_landuse();
296
+
CALL geofaker.point_in_place_landuse();
297
297
298
298
299
-
CREATE PROCEDURE geo_faker.points_around_point()
300
-
LANGUAGE plpgsql
301
-
AS $$
302
-
DECLARE
303
-
stores_to_process BIGINT;
299
+
CREATE PROCEDURE geofaker.points_around_point()
300
+
LANGUAGE plpgsql
301
+
AS $$
302
+
DECLARE
303
+
stores_to_process BIGINT;
304
304
t_row faker_store_location%rowtype;
305
-
BEGIN
305
+
BEGIN
306
306
307
-
SELECTCOUNT(*) INTO stores_to_process
308
-
FROM faker_store_location
309
-
;
310
-
RAISE NOTICE 'Stores to process: %', stores_to_process;
307
+
SELECTCOUNT(*) INTO stores_to_process
308
+
FROM faker_store_location
309
+
;
310
+
RAISE NOTICE 'Generating customers for % stores...', stores_to_process;
311
311
312
-
DROPTABLE IF EXISTS faker_customer_location;
313
-
CREATE TEMP TABLE faker_customer_location
314
-
(
315
-
id BIGINTNOT NULL GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
316
-
store_id BIGINTNOT NULL,
317
-
customer_id BIGINTNOT NULL,
318
-
geom GEOMETRY(POINT, 3857) NOT NULL
319
-
);
312
+
DROPTABLE IF EXISTS faker_customer_location;
313
+
CREATE TEMP TABLE faker_customer_location
314
+
(
315
+
id BIGINTNOT NULL GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
316
+
store_id BIGINTNOT NULL,
317
+
customer_id BIGINTNOT NULL,
318
+
geom GEOMETRY(POINT, 3857) NOT NULL
319
+
);
320
320
321
321
322
322
FOR t_row INSELECT*FROM faker_store_location LOOP
323
-
RAISE NOTICE 'Store ID: %', t_row.id;
323
+
IF t_row.store_id % 10=0 THEN
324
+
RAISE NOTICE 'Store ID: %', t_row.store_id;
325
+
END IF;
324
326
325
327
DROPTABLE IF EXISTS place_buffer;
326
328
CREATE TEMP TABLE place_buffer AS
327
-
SELECTid ASstore_id, geom, ST_Buffer(geom, 5000) AS geom_buffer
329
+
SELECT store_id, geom, ST_Buffer(geom, 5000) AS geom_buffer
328
330
FROM faker_store_location
329
-
WHEREid=t_row.id
331
+
WHEREstore_id=t_row.store_id
330
332
;
331
333
332
334
DROPTABLE IF EXISTS store_potential_customers;
333
335
CREATE TEMP TABLE store_potential_customers AS
334
336
SELECT store_id,
335
-
geo_faker.n_points_in_polygon(geom_buffer, 1000)
337
+
geofaker.n_points_in_polygon(geom_buffer, 1000)
336
338
AS geom
337
339
FROM place_buffer
338
340
;
@@ -374,7 +376,7 @@ END;
374
376
$$;
375
377
376
378
377
-
COMMENT ON PROCEDURE geo_faker.points_around_point IS 'Creates fake customer locations around a store. Locations are snapped to roads. Locations not scoped to landuse at this time. Requires faker_store_location temp table with fake store data.';
379
+
COMMENT ON PROCEDURE geofaker.points_around_point IS 'Creates fake customer locations around a store. Locations are snapped to roads. Locations not scoped to landuse at this time. Requires faker_store_location temp table with fake store data.';
0 commit comments